@nascentdigital/funnel-editor 6.1.7 → 7.0.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.
Files changed (82) hide show
  1. package/dist/collection/components/CollectionHeader.js +17 -3
  2. package/dist/core/components/fields/EnumField.js +3 -1
  3. package/dist/core/components/fields/FieldHeader.js +16 -23
  4. package/dist/core/components/fields/FieldLayout.d.ts +1 -1
  5. package/dist/core/components/fields/FieldLayout.js +10 -18
  6. package/dist/core/components/fields/collection/CollectionEditor.js +7 -7
  7. package/dist/core/components/index.d.ts +1 -0
  8. package/dist/core/components/index.js +1 -0
  9. package/dist/core/components/interaction/Combobox.js +17 -28
  10. package/dist/core/components/interaction/Popup.js +14 -2
  11. package/dist/core/components/interaction/QuickPicker.js +0 -1
  12. package/dist/core/components/panels/MessagePanel.d.ts +7 -0
  13. package/dist/core/components/panels/MessagePanel.js +53 -0
  14. package/dist/core/components/panels/index.d.ts +2 -0
  15. package/dist/core/components/panels/index.js +18 -0
  16. package/dist/core/components/panels/visual/MediaEditor.d.ts +12 -0
  17. package/dist/core/components/panels/visual/MediaEditor.js +47 -0
  18. package/dist/core/components/panels/visual/VisualPanel.d.ts +7 -0
  19. package/dist/core/components/panels/visual/VisualPanel.js +332 -0
  20. package/dist/core/components/panels/visual/index.d.ts +1 -0
  21. package/dist/core/components/panels/visual/index.js +17 -0
  22. package/dist/core/components/visuals/Icon.d.ts +1 -1
  23. package/dist/core/components/visuals/Icon.js +12 -0
  24. package/dist/core/domain/Block.d.ts +18 -8
  25. package/dist/core/domain/Block.js +101 -78
  26. package/dist/core/domain/BlockConfiguration.d.ts +38 -32
  27. package/dist/core/domain/BlockConfiguration.js +348 -255
  28. package/dist/core/domain/CollectionFieldProxy.d.ts +1 -0
  29. package/dist/core/domain/CollectionFieldProxy.js +5 -0
  30. package/dist/core/domain/CollectionSummary.d.ts +1 -1
  31. package/dist/core/domain/CollectionSummary.js +1 -1
  32. package/dist/core/domain/Collections.d.ts +2 -0
  33. package/dist/core/domain/Collections.js +6 -0
  34. package/dist/core/domain/IPage.d.ts +3 -2
  35. package/dist/core/domain/Item.d.ts +1 -1
  36. package/dist/core/domain/ItemBase.d.ts +2 -0
  37. package/dist/core/domain/ItemBase.js +9 -0
  38. package/dist/core/domain/Page.d.ts +1 -1
  39. package/dist/core/domain/SectionBlock.d.ts +4 -5
  40. package/dist/core/domain/SectionBlock.js +3 -10
  41. package/dist/core/hooks/useBlockConfiguration.d.ts +1 -7
  42. package/dist/core/hooks/useBlockConfiguration.js +1 -6
  43. package/dist/core/repository/PageSerializer.js +11 -10
  44. package/dist/core/repository/SerializeCollectionUpdate.js +4 -4
  45. package/dist/core/repository/SerializePageUpdate.d.ts +2 -1
  46. package/dist/core/repository/SerializePageUpdate.js +79 -24
  47. package/dist/page/components/BlockEditor.js +3 -3
  48. package/dist/page/components/config/BlockConfigButton.d.ts +3 -1
  49. package/dist/page/components/config/BlockConfigButton.js +12 -24
  50. package/dist/page/components/config/BlockPreview.d.ts +7 -6
  51. package/dist/page/components/config/BlockPreview.js +30 -15
  52. package/dist/page/components/config/index.d.ts +1 -2
  53. package/dist/page/components/config/index.js +1 -2
  54. package/dist/page/components/config/preview/ColumnLayout.d.ts +7 -4
  55. package/dist/page/components/config/preview/ColumnLayout.js +14 -2
  56. package/dist/page/components/config/preview/ItemLayout.d.ts +7 -4
  57. package/dist/page/components/config/preview/ItemLayout.js +24 -11
  58. package/dist/page/components/config/preview/ListPanel.d.ts +7 -4
  59. package/dist/page/components/config/preview/ListPanel.js +4 -2
  60. package/dist/page/components/config/preview/MessagePanel.d.ts +7 -4
  61. package/dist/page/components/config/preview/MessagePanel.js +6 -3
  62. package/dist/page/components/config/preview/Panel.d.ts +14 -4
  63. package/dist/page/components/config/preview/Panel.js +25 -7
  64. package/dist/page/components/config/preview/PreviewSize.d.ts +1 -0
  65. package/dist/page/components/config/preview/PreviewSize.js +2 -0
  66. package/dist/page/components/config/preview/RowLayout.d.ts +7 -4
  67. package/dist/page/components/config/preview/RowLayout.js +15 -3
  68. package/dist/page/components/config/preview/StackLayout.d.ts +7 -4
  69. package/dist/page/components/config/preview/StackLayout.js +14 -2
  70. package/dist/page/components/config/preview/VisualPanel.d.ts +7 -4
  71. package/dist/page/components/config/preview/VisualPanel.js +7 -5
  72. package/dist/page/components/config/preview/index.d.ts +2 -0
  73. package/dist/page/components/config/preview/index.js +2 -0
  74. package/dist/page/components/panels/BlockConfigPanel.d.ts +7 -1
  75. package/dist/page/components/panels/BlockConfigPanel.js +9 -7
  76. package/dist/page/screens/PageEditor.js +3 -4
  77. package/dist/styles/index.css +74 -56
  78. package/package.json +2 -2
  79. package/dist/page/components/config/BlockConfigurationProvider.d.ts +0 -16
  80. package/dist/page/components/config/BlockConfigurationProvider.js +0 -25
  81. package/dist/page/components/config/useBlockConfiguration$.d.ts +0 -3
  82. package/dist/page/components/config/useBlockConfiguration$.js +0 -22
@@ -28,6 +28,7 @@ export declare class CollectionFieldProxy<TCollection extends Schema.Collection
28
28
  private constructor();
29
29
  get events$(): Observable<CollectionFieldProxy.Events>;
30
30
  get stable$(): Observable<boolean>;
31
+ get fieldChanged$(): Observable<Field.Event>;
31
32
  get id(): Schema.Collection.Id;
32
33
  get type(): Schema.Collection.Type;
33
34
  get assets(): ReadonlyArray<Asset>;
@@ -64,6 +64,11 @@ class CollectionFieldProxy {
64
64
  return this.eventBus.events$
65
65
  .pipe((0, rxjs_1.map)(() => !this._syncing && !this.modified), (0, rxjs_1.distinctUntilChanged)());
66
66
  }
67
+ get fieldChanged$() {
68
+ return this.eventBus.events$
69
+ .pipe((0, rxjs_1.filter)(funnel_core_1.Field.Event.filter), (0, rxjs_1.filter)(event => (event.type === 'changed' || event.type === 'reset')
70
+ && this.fields.includes(event.field)));
71
+ }
67
72
  get id() {
68
73
  // throw if it's not a ref
69
74
  const { _initialValue } = this;
@@ -12,7 +12,7 @@ export declare class CollectionSummary {
12
12
  constructor(args: CollectionSummary.ConstructorArgs);
13
13
  get type(): Schema.Collection.Type;
14
14
  hasLanguage(language: Language): boolean;
15
- findCollection({ language, fallbackLanguage }: CollectionSummary.GetClosestOptions): CollectionSummary.CollectionRef;
15
+ getCollection({ language, fallbackLanguage }: CollectionSummary.GetClosestOptions): CollectionSummary.CollectionRef | undefined;
16
16
  getClosestCollectionRef(language: Language, fallback?: Language): ICollection.Ref | undefined;
17
17
  }
18
18
  export declare namespace CollectionSummary {
@@ -22,7 +22,7 @@ class CollectionSummary {
22
22
  hasLanguage(language) {
23
23
  return this.collections.some(collection => collection.language === language);
24
24
  }
25
- findCollection({ language, fallbackLanguage }) {
25
+ getCollection({ language, fallbackLanguage }) {
26
26
  var _a, _b;
27
27
  const { collections } = this;
28
28
  return (_b = (_a = collections.find(collection => collection.language === language)) !== null && _a !== void 0 ? _a : ((fallbackLanguage && fallbackLanguage !== language) ? collections.find(collection => collection.language === fallbackLanguage) : undefined)) !== null && _b !== void 0 ? _b : collections[0];
@@ -14,6 +14,8 @@ export declare class Collections {
14
14
  private readonly _subscription;
15
15
  constructor(args: Collections.ConstructorArgs);
16
16
  get events$(): Observable<Collections.Event>;
17
+ 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")[];
18
+ get defaultLanguage(): "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";
17
19
  get state(): Collections.State;
18
20
  private set state(value);
19
21
  get ready(): boolean;
@@ -18,6 +18,12 @@ class Collections {
18
18
  get events$() {
19
19
  return this._eventBus.events$;
20
20
  }
21
+ get languages() {
22
+ return funnel_core_1.RegionsConfig.getLanguages(funnel_core_1.AppConfig.brandConfig().regionalization);
23
+ }
24
+ get defaultLanguage() {
25
+ return funnel_core_1.RegionsConfig.getDefaultLanguage(funnel_core_1.AppConfig.brandConfig().regionalization);
26
+ }
21
27
  get state() {
22
28
  return this._state;
23
29
  }
@@ -2,6 +2,7 @@ import { EventBus, Field, FieldList, FieldModel, Language, ObjectField, Schema }
2
2
  import type { Observable } from 'rxjs';
3
3
  import type { Asset } from './Asset';
4
4
  import type { Block } from './Block';
5
+ import type { BlockConfiguration } from './BlockConfiguration';
5
6
  import type { IAssetStore } from './IAssetStore';
6
7
  import type { ICollectionStore } from './ICollectionStore';
7
8
  import type { IPageRefStore } from './IPageRefStore';
@@ -40,7 +41,7 @@ export interface IPage extends IAssetStore, ICollectionStore, IPageRefStore, ITa
40
41
  export declare namespace IPage {
41
42
  type Content = ReadonlyArray<Block | Section>;
42
43
  type Area = 'discover' | 'content';
43
- type Savable = Section | Block | FieldModel;
44
+ type Savable = Section | Block | FieldModel | BlockConfiguration;
44
45
  type Item = Block | SectionBlock | Section | PageSettings;
45
46
  type Errors = {
46
47
  page: IPage;
@@ -62,7 +63,7 @@ export declare namespace IPage {
62
63
  summary: PageSummary;
63
64
  page?: IPage;
64
65
  };
65
- type Events = Event | Item.Event | Field.Event | ObjectField.Event | FieldList.Event;
66
+ type Events = Event | Item.Event | BlockConfiguration.Event | Field.Event | ObjectField.Event | FieldList.Event;
66
67
  interface Event extends EventBus.Event<'Page', Event.Type> {
67
68
  page: IPage;
68
69
  }
@@ -11,7 +11,7 @@ export declare namespace Item {
11
11
  item: Type;
12
12
  }
13
13
  namespace Event {
14
- type Type = 'changed';
14
+ type Type = 'ready' | 'changed';
15
15
  function filter(event: EventBus.Event): event is Event;
16
16
  function create(event: EventBus.Args<Event>): Event;
17
17
  }
@@ -25,7 +25,9 @@ export declare abstract class ItemBase<T extends Item.Type> {
25
25
  private get parentContext();
26
26
  get parent(): Section | IPage;
27
27
  get area(): IPage.Area;
28
+ get ready(): boolean;
28
29
  bind(parentContext: ItemBase.ParentContext): void;
30
+ protected onBind(parentContext: ItemBase.ParentContext): void;
29
31
  getClosestBlock(direction?: 'prev' | 'next'): SectionBlock | Block | undefined;
30
32
  delete(): undefined;
31
33
  abstract repair(): void;
@@ -67,6 +67,9 @@ class ItemBase {
67
67
  get area() {
68
68
  return this.parentContext.area;
69
69
  }
70
+ get ready() {
71
+ return this._parentContext !== undefined;
72
+ }
70
73
  bind(parentContext) {
71
74
  // throw if already bound
72
75
  if (this._parentContext) {
@@ -78,6 +81,12 @@ class ItemBase {
78
81
  if (parentContext.parent instanceof _1.Section) {
79
82
  this._required = true;
80
83
  }
84
+ // call bind
85
+ this.onBind(parentContext);
86
+ // mark ready
87
+ this.raiseEvent('ready');
88
+ }
89
+ onBind(parentContext) {
81
90
  }
82
91
  getClosestBlock(direction) {
83
92
  // search for closest sibling
@@ -74,7 +74,7 @@ export declare class Page implements IAssetStore, ICollectionStore, IPageRefStor
74
74
  get blocks(): (Block<Block.SchemaType> | SectionBlock<Schema.Block<string, any, any>>)[];
75
75
  get deleteBlocks(): ReadonlyArray<Block>;
76
76
  get firstBlock(): Block<Block.SchemaType> | SectionBlock<Schema.Block<string, any, any>> | undefined;
77
- get firstItem(): Section | Block<Block.SchemaType>;
77
+ get firstItem(): Block<Block.SchemaType> | Section;
78
78
  get published(): boolean;
79
79
  get modified(): boolean;
80
80
  get updatedOn(): number;
@@ -1,8 +1,8 @@
1
1
  import { FieldModel, Schema } from '@nascentdigital/funnel-core';
2
2
  import { Tagged } from 'type-fest';
3
3
  import { Block } from './Block';
4
- import { BlockConfiguration } from './BlockConfiguration';
5
4
  import { ItemBase } from './ItemBase';
5
+ import ParentContext = ItemBase.ParentContext;
6
6
  export declare class SectionBlock<TBlock extends Schema.Block = Schema.Block> extends ItemBase<SectionBlock<TBlock>> {
7
7
  readonly id: SectionBlock.Id;
8
8
  readonly block: Block<TBlock>;
@@ -10,9 +10,9 @@ export declare class SectionBlock<TBlock extends Schema.Block = Schema.Block> ex
10
10
  get schema(): TBlock;
11
11
  get identifier(): string;
12
12
  get name(): string;
13
- get config(): ReadonlyArray<FieldModel>;
13
+ get configuration(): import("./BlockConfiguration").BlockConfiguration;
14
14
  get fields(): ReadonlyArray<FieldModel>;
15
- get nameField(): import("@nascentdigital/funnel-core").Field<Schema.TextField>;
15
+ get nameField(): import("@nascentdigital/funnel-core").Field<Schema.TextField> | undefined;
16
16
  get messageFields(): readonly FieldModel[];
17
17
  get visualFields(): readonly FieldModel[];
18
18
  get listsFields(): readonly FieldModel[];
@@ -23,8 +23,7 @@ export declare class SectionBlock<TBlock extends Schema.Block = Schema.Block> ex
23
23
  get changes(): Block.Changes;
24
24
  get valid(): boolean;
25
25
  get errors(): Block.Errors;
26
- getConfiguration(): BlockConfiguration;
27
- bind(parentContext: ItemBase.ParentContext): void;
26
+ protected onBind(parentContext: ParentContext): void;
28
27
  repair(): void;
29
28
  static for({ block, parentContext }: SectionBlock.ForArgs): SectionBlock<Block.SchemaType>;
30
29
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SectionBlock = void 0;
4
4
  const funnel_core_1 = require("@nascentdigital/funnel-core");
5
- const BlockConfiguration_1 = require("./BlockConfiguration");
6
5
  const ItemBase_1 = require("./ItemBase");
7
6
  // class
8
7
  class SectionBlock extends ItemBase_1.ItemBase {
@@ -22,8 +21,8 @@ class SectionBlock extends ItemBase_1.ItemBase {
22
21
  get name() {
23
22
  return this.block.name;
24
23
  }
25
- get config() {
26
- return this.block.config;
24
+ get configuration() {
25
+ return this.block.configuration;
27
26
  }
28
27
  get fields() {
29
28
  return this.block.fields;
@@ -65,13 +64,7 @@ class SectionBlock extends ItemBase_1.ItemBase {
65
64
  get errors() {
66
65
  return this.block.errors;
67
66
  }
68
- getConfiguration() {
69
- const { root } = this;
70
- return new BlockConfiguration_1.BlockConfiguration({ block: this, assetStore: root, collectionStore: root });
71
- }
72
- bind(parentContext) {
73
- // bind base
74
- super.bind(parentContext);
67
+ onBind(parentContext) {
75
68
  // bind block
76
69
  this.block.bind(parentContext);
77
70
  }
@@ -1,8 +1,2 @@
1
1
  import { BlockConfiguration } from '../domain';
2
- export declare function useBlockConfiguration(newConfiguration?: BlockConfiguration): BlockConfiguration | undefined;
3
- export declare const BlockConfigurationContext: import("react").Context<BlockConfigurationContext.Data>;
4
- export declare namespace BlockConfigurationContext {
5
- type Data = {
6
- configuration?: BlockConfiguration;
7
- };
8
- }
2
+ export declare function useBlockConfiguration(configuration?: BlockConfiguration): BlockConfiguration | undefined;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockConfigurationContext = void 0;
4
3
  exports.useBlockConfiguration = useBlockConfiguration;
5
4
  const client_1 = require("@nascentdigital/funnel-ui/client");
6
5
  const react_1 = require("react");
7
6
  // hook
8
- function useBlockConfiguration(newConfiguration) {
7
+ function useBlockConfiguration(configuration) {
9
8
  // bind touch (for re-rendering parent)
10
- const { configuration: existingConfiguration } = (0, react_1.useContext)(exports.BlockConfigurationContext);
11
- const configuration = newConfiguration !== null && newConfiguration !== void 0 ? newConfiguration : existingConfiguration;
12
9
  const touch = (0, client_1.useTouch)();
13
10
  // listen to configuration changes
14
11
  (0, react_1.useEffect)(() => {
@@ -24,5 +21,3 @@ function useBlockConfiguration(newConfiguration) {
24
21
  // return configuration
25
22
  return configuration;
26
23
  }
27
- // context
28
- exports.BlockConfigurationContext = (0, react_1.createContext)({});
@@ -148,8 +148,8 @@ var PageSerializer;
148
148
  PageSerializer.deserializeSectionBlock = deserializeSectionBlock;
149
149
  function deserializeBlock({ key, eventBus, schema, content: blockContent, snapshot }) {
150
150
  // throw if there's a type mismatch
151
- const { type = schema.type, version = schema.version, config = {}, fields = {} } = blockContent !== null && blockContent !== void 0 ? blockContent : {};
152
- const { config: snapshotConfig = {}, fields: snapshotFields = {} } = snapshot !== null && snapshot !== void 0 ? snapshot : {};
151
+ const { type = schema.type, version = schema.version, config = {}, configMobile, configTablet, fields = {} } = blockContent !== null && blockContent !== void 0 ? blockContent : {};
152
+ const { config: snapshotConfig = {}, configMobile: snapshotConfigMobile, configTablet: snapshotConfigTablet, fields: snapshotFields = {} } = snapshot !== null && snapshot !== void 0 ? snapshot : {};
153
153
  if (type !== schema.type) {
154
154
  throw new funnel_core_1.IllegalStateError(`Schema type mismatch for ${schema.name} block - expected "${schema.type}", found "${type}"`);
155
155
  }
@@ -169,14 +169,15 @@ var PageSerializer;
169
169
  content: fields[id],
170
170
  snapshot: snapshotFields[id]
171
171
  })),
172
- config: Object.entries(schema.config).map(([id, schema]) => FieldSerializer_1.FieldSerializer.deserializeField({
173
- id,
174
- eventBus,
175
- schema: schema,
176
- content: config[id],
177
- snapshot: snapshotConfig[id],
178
- config: true
179
- })),
172
+ configData: {
173
+ base: { config: config, configSnapshot: snapshotConfig },
174
+ mobile: configMobile || snapshotConfigMobile
175
+ ? { config: configMobile !== null && configMobile !== void 0 ? configMobile : {}, configSnapshot: snapshotConfigMobile !== null && snapshotConfigMobile !== void 0 ? snapshotConfigMobile : {} }
176
+ : undefined,
177
+ tablet: configTablet || snapshotConfigTablet
178
+ ? { config: configTablet !== null && configTablet !== void 0 ? configTablet : {}, configSnapshot: snapshotConfigTablet !== null && snapshotConfigTablet !== void 0 ? snapshotConfigTablet : {} }
179
+ : undefined,
180
+ },
180
181
  required: schema.required,
181
182
  exists: blockContent !== undefined,
182
183
  name: config.name
@@ -70,14 +70,14 @@ var SerializeCollectionUpdate;
70
70
  }
71
71
  SerializeCollectionUpdate.serializeFieldUpdate = serializeFieldUpdate;
72
72
  function serializeListUpdate(updates, list, parentPath, savables) {
73
- var _a, _b;
73
+ var _a, _b, _c;
74
74
  // create list if it's new
75
75
  if (list.isNew) {
76
76
  // add new list
77
77
  updates.push({
78
78
  type: 'value',
79
79
  path: [...parentPath, list.id],
80
- value: funnel_core_1.Schema.Field.Data.newValue('list')
80
+ value: (_a = list.value) !== null && _a !== void 0 ? _a : funnel_core_1.Schema.Field.Data.newValue('list')
81
81
  });
82
82
  // track save
83
83
  savables.push(list);
@@ -98,8 +98,8 @@ var SerializeCollectionUpdate;
98
98
  // track insert/update
99
99
  const path = [...parentPath, list.id];
100
100
  const { value: currentValue, items: fields, initialValue } = list;
101
- const currentItems = (_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) !== null && _a !== void 0 ? _a : [];
102
- const initialItems = (_b = initialValue === null || initialValue === void 0 ? void 0 : initialValue.value) !== null && _b !== void 0 ? _b : [];
101
+ const currentItems = (_b = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) !== null && _b !== void 0 ? _b : [];
102
+ const initialItems = (_c = initialValue === null || initialValue === void 0 ? void 0 : initialValue.value) !== null && _c !== void 0 ? _c : [];
103
103
  const fieldIds = [];
104
104
  currentItems.forEach((item, index) => {
105
105
  // track id
@@ -3,8 +3,9 @@ import { Block, IPage, Section } from '../domain';
3
3
  export declare namespace SerializePageUpdate {
4
4
  function serializeSectionUpdate(updates: Schema.Page.Update[], section: Section, parentPath: string, savables: IPage.Savable[]): void;
5
5
  function serializeBlockUpdate(updates: Schema.Page.Update[], block: Block, parentPath: string, savables: IPage.Savable[]): void;
6
+ function serializeBlockConfigUpdate(updates: Schema.Page.Update[], block: Block, parentPath: ReadonlyArray<string>, savables: IPage.Savable[]): void;
6
7
  function serializeFieldsUpdate(updates: Schema.Page.Update[], fields: ReadonlyArray<FieldModel>, parentPath: ReadonlyArray<string>, savables: IPage.Savable[]): Schema.Page.Update[];
7
8
  function serializeObjectFieldUpdate(updates: Schema.Page.Update[], field: ObjectField, parentPath: ReadonlyArray<string>, savables: IPage.Savable[]): void;
8
- function serializeFieldUpdate(updates: Schema.Page.Update[], field: Field, parentPath: ReadonlyArray<string>, savables: IPage.Savable[]): void;
9
9
  function serializeListUpdate(updates: Schema.Page.Update[], list: FieldList, parentPath: ReadonlyArray<string>, savables: IPage.Savable[]): void;
10
+ function serializeFieldUpdate(updates: Schema.Page.Update[], field: Field, parentPath: ReadonlyArray<string>, savables: IPage.Savable[]): void;
10
11
  }
@@ -5,6 +5,7 @@ const funnel_core_1 = require("@nascentdigital/funnel-core");
5
5
  // namespace
6
6
  var SerializePageUpdate;
7
7
  (function (SerializePageUpdate) {
8
+ const log = funnel_core_1.Logger.get('editor:page:repo');
8
9
  // helpers
9
10
  function serializeSectionUpdate(updates, section, parentPath, savables) {
10
11
  // track insert/update
@@ -13,6 +14,7 @@ var SerializePageUpdate;
13
14
  const { blocks, initialBlocks = [] } = section;
14
15
  const blockIds = [];
15
16
  blocks.forEach((sectionBlock, index) => {
17
+ var _a;
16
18
  // track id
17
19
  const { id, block } = sectionBlock;
18
20
  blockIds.push(id);
@@ -32,9 +34,10 @@ var SerializePageUpdate;
32
34
  });
33
35
  // mark changed
34
36
  sectionChanged = true;
37
+ // track block configuration (if changed)
38
+ savables.push(block.configuration);
35
39
  // track nested savables for section-block insertion
36
- const fields = [...block.config, ...block.fields];
37
- fields.forEach(field => {
40
+ block.fields.forEach(field => {
38
41
  if (field.modified) {
39
42
  savables.push(field);
40
43
  }
@@ -42,8 +45,9 @@ var SerializePageUpdate;
42
45
  }
43
46
  // recurse update if it's set
44
47
  else if (block.modified) {
48
+ log.v(`serializeConfig - block modified "${block.name}"`, block);
45
49
  // track name field
46
- if (block.nameField.modified) {
50
+ if ((_a = block.nameField) === null || _a === void 0 ? void 0 : _a.modified) {
47
51
  // send update
48
52
  updates.push({
49
53
  type: 'section.blockName',
@@ -54,11 +58,14 @@ var SerializePageUpdate;
54
58
  // track change
55
59
  savables.push(block.nameField);
56
60
  }
57
- // serialize config fields
58
- serializeFieldsUpdate(updates, block.config, [...path, id, 'config'], savables);
61
+ // serialize configuration updates
62
+ serializeBlockConfigUpdate(updates, block, [...path, id], savables);
59
63
  // serialize content fields
60
64
  serializeFieldsUpdate(updates, block.fields, [...path, id, 'fields'], savables);
61
65
  }
66
+ else {
67
+ log.v(`serializeConfig - block NOT modified "${block.name}"`, block);
68
+ }
62
69
  });
63
70
  // track delete/reorder
64
71
  let reordered = false;
@@ -110,9 +117,10 @@ var SerializePageUpdate;
110
117
  });
111
118
  // track block
112
119
  savables.push(block);
120
+ // track configuration
121
+ savables.push(block.configuration);
113
122
  // track nested savables for block insertion
114
- const fields = [...block.config, ...block.fields];
115
- fields.forEach(field => {
123
+ block.fields.forEach(field => {
116
124
  if (field.modified) {
117
125
  savables.push(field);
118
126
  }
@@ -120,13 +128,60 @@ var SerializePageUpdate;
120
128
  }
121
129
  // or just track updated fields
122
130
  else {
123
- // serialize config fields
124
- serializeFieldsUpdate(updates, block.config, [parentPath, block.key, 'config'], savables);
131
+ // serialize configuration updates
132
+ serializeBlockConfigUpdate(updates, block, [parentPath, block.key], savables);
125
133
  // serialize content fields
126
134
  serializeFieldsUpdate(updates, block.fields, [parentPath, block.key, 'fields'], savables);
127
135
  }
128
136
  }
129
137
  SerializePageUpdate.serializeBlockUpdate = serializeBlockUpdate;
138
+ function serializeBlockConfigUpdate(updates, block, parentPath, savables) {
139
+ log.v(`serializeConfig - checking config for block "${block.name}"`, block);
140
+ // update base if changed
141
+ let updated = false;
142
+ const { configData, configuration } = block;
143
+ const { value } = configuration;
144
+ funnel_core_1.Schema.Block.Config.Variant.values.forEach(variant => {
145
+ var _a;
146
+ // skip if block data is unchanged
147
+ const fromConfig = (_a = configData[variant]) === null || _a === void 0 ? void 0 : _a.config;
148
+ const toConfig = value[variant];
149
+ if (funnel_core_1.Value.equals(fromConfig, toConfig)) {
150
+ log.s(`serializeConfig - ${variant} is unchanged`, { fromConfig, toConfig });
151
+ }
152
+ // or delete if there's no new value
153
+ else if (!toConfig || Object.keys(toConfig).length === 0) {
154
+ log.v(`serializeConfig - removing ${variant}`, { fromConfig, toConfig });
155
+ // track update
156
+ updates.push({
157
+ type: 'block.config',
158
+ path: [...parentPath],
159
+ variant,
160
+ value: null
161
+ });
162
+ // track update
163
+ updated = true;
164
+ }
165
+ // or set config
166
+ else {
167
+ log.v(`serializeConfig - updating ${variant} config`, { fromConfig, toConfig });
168
+ // set config
169
+ updates.push({
170
+ type: 'block.config',
171
+ path: [...parentPath],
172
+ variant,
173
+ value: toConfig
174
+ });
175
+ // track update
176
+ updated = true;
177
+ }
178
+ });
179
+ // track config if updated
180
+ if (updated) {
181
+ savables.push(configuration);
182
+ }
183
+ }
184
+ SerializePageUpdate.serializeBlockConfigUpdate = serializeBlockConfigUpdate;
130
185
  function serializeFieldsUpdate(updates, fields, parentPath, savables) {
131
186
  // handle fields in block
132
187
  fields.forEach(field => {
@@ -177,21 +232,6 @@ var SerializePageUpdate;
177
232
  }
178
233
  }
179
234
  SerializePageUpdate.serializeObjectFieldUpdate = serializeObjectFieldUpdate;
180
- function serializeFieldUpdate(updates, field, parentPath, savables) {
181
- var _a;
182
- // track change if modified (ignore if field is sandboxed)
183
- if (field.modified && !field.sandboxed) {
184
- // set field
185
- updates.push({
186
- type: 'value',
187
- path: [...parentPath, field.id],
188
- value: ((_a = field.value) !== null && _a !== void 0 ? _a : null)
189
- });
190
- // track save
191
- savables.push(field);
192
- }
193
- }
194
- SerializePageUpdate.serializeFieldUpdate = serializeFieldUpdate;
195
235
  function serializeListUpdate(updates, list, parentPath, savables) {
196
236
  var _a, _b;
197
237
  // create list if it's new
@@ -289,4 +329,19 @@ var SerializePageUpdate;
289
329
  }
290
330
  }
291
331
  SerializePageUpdate.serializeListUpdate = serializeListUpdate;
332
+ function serializeFieldUpdate(updates, field, parentPath, savables) {
333
+ var _a;
334
+ // track change if modified (ignore if field is sandboxed)
335
+ if (field.modified && !field.sandboxed) {
336
+ // set field
337
+ updates.push({
338
+ type: 'value',
339
+ path: [...parentPath, field.id],
340
+ value: ((_a = field.value) !== null && _a !== void 0 ? _a : null)
341
+ });
342
+ // track save
343
+ savables.push(field);
344
+ }
345
+ }
346
+ SerializePageUpdate.serializeFieldUpdate = serializeFieldUpdate;
292
347
  })(SerializePageUpdate || (exports.SerializePageUpdate = SerializePageUpdate = {}));
@@ -61,9 +61,9 @@ function BlockEditor({ className, block, headerActions, onSelectItem }) {
61
61
  const { messageFields, visualFields, listsFields, extendedFields } = block;
62
62
  return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(className, 'max-h-full h-full flex flex-col'), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center px-l6 pt-l10 pb-l4", children: [(0, jsx_runtime_1.jsx)("h2", { className: "heading-lg flex-1", children: (0, jsx_runtime_1.jsx)("a", { href: core_1.IPage.getPreviewUrl(page.url).href, target: `${page.brand}.preview`, children: block.name }) }), (0, jsx_runtime_1.jsxs)("div", { className: "shrink-0 flex items-center gap-l5", children: [headerActions, block.canDelete &&
63
63
  (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.IconButton, { anchorId: anchorId, className: "DeleteAction text-content-primary hover:text-destructive shrink-0", variant: "util", icon: "EllipsisVertical", onClick: e => menu.open(anchorId) }), (0, jsx_runtime_1.jsx)(core_1.Menu, { controller: menu, onItemClick: onMenuClick })] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1 flex flex-col gap-l8 px-l6 pb-l10 overflow-y-scroll scrollbar-thin scroller-fade-top bg-background", tabIndex: -1, children: [messageFields.length > 0 &&
64
- (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { title: "Messaging", actions: (0, jsx_runtime_1.jsx)(config_1.BlockConfigButton, { target: "message" }), fields: messageFields }), visualFields.length > 0 &&
65
- (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { title: "Visual", actions: (0, jsx_runtime_1.jsx)(config_1.BlockConfigButton, { target: "visual" }), fields: visualFields }), listsFields.length > 0 &&
66
- (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { title: "List", actions: (0, jsx_runtime_1.jsx)(config_1.BlockConfigButton, { target: "list" }), fields: listsFields }), extendedFields.length > 0 &&
64
+ (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { title: "Messaging", actions: (0, jsx_runtime_1.jsx)(config_1.BlockConfigButton, { target: "message", block: block }), fields: messageFields }), visualFields.length > 0 &&
65
+ (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { title: "Visual", actions: (0, jsx_runtime_1.jsx)(config_1.BlockConfigButton, { target: "visual", block: block }), fields: visualFields }), listsFields.length > 0 &&
66
+ (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { title: "List", actions: (0, jsx_runtime_1.jsx)(config_1.BlockConfigButton, { target: "list", block: block }), fields: listsFields }), extendedFields.length > 0 &&
67
67
  (0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { fields: extendedFields })] })] }));
68
68
  }
69
69
  const blockMenu = [
@@ -1,8 +1,10 @@
1
1
  import { PropsWithChildren } from 'react';
2
- export declare function BlockConfigButton({ target, anchorId: anchorOverrideId, children }: BlockConfigButton.Props): import("react/jsx-runtime").JSX.Element | null;
2
+ import { Block, SectionBlock } from '../../../core';
3
+ export declare function BlockConfigButton({ block, target, anchorId: anchorOverrideId, children }: BlockConfigButton.Props): import("react/jsx-runtime").JSX.Element;
3
4
  export declare namespace BlockConfigButton {
4
5
  type Target = 'block' | 'message' | 'visual' | 'list';
5
6
  type Props = PropsWithChildren & {
7
+ block: Block | SectionBlock;
6
8
  target: Target;
7
9
  anchorId?: string;
8
10
  };