sequential-workflow-designer 0.35.3 → 0.37.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/lib/cjs/index.cjs CHANGED
@@ -152,7 +152,7 @@ class SimpleEvent {
152
152
  count() {
153
153
  return this.listeners.length;
154
154
  }
155
- first() {
155
+ once() {
156
156
  return new Promise(resolve => {
157
157
  const handler = (value) => {
158
158
  this.unsubscribe(handler);
@@ -1334,7 +1334,7 @@ class DefaultSequenceComponent {
1334
1334
  exports.ClickCommandType = void 0;
1335
1335
  (function (ClickCommandType) {
1336
1336
  ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
1337
- ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
1337
+ ClickCommandType[ClickCommandType["changePreferences"] = 2] = "changePreferences";
1338
1338
  ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
1339
1339
  ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
1340
1340
  })(exports.ClickCommandType || (exports.ClickCommandType = {}));
@@ -2551,7 +2551,12 @@ class StepComponentViewContextFactory {
2551
2551
  createPlaceholderForGap: componentContext.services.placeholder.createForGap.bind(componentContext.services.placeholder),
2552
2552
  createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
2553
2553
  getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
2554
- setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
2554
+ createPreferenceChange: (key, value) => {
2555
+ return {
2556
+ key: preferenceKeyPrefix + key,
2557
+ value
2558
+ };
2559
+ }
2555
2560
  };
2556
2561
  }
2557
2562
  }
@@ -2864,11 +2869,19 @@ class StepDuplicator {
2864
2869
  }
2865
2870
  duplicate(step) {
2866
2871
  const newStep = ObjectCloner.deepClone(step);
2867
- newStep.id = this.uidGenerator();
2872
+ const duplicatedIds = [];
2873
+ const newId = this.uidGenerator();
2874
+ duplicatedIds.push([step.id, newId]);
2875
+ newStep.id = newId;
2868
2876
  this.definitionWalker.forEachChildren(newStep, s => {
2869
- s.id = this.uidGenerator();
2877
+ const newId = this.uidGenerator();
2878
+ duplicatedIds.push([s.id, newId]);
2879
+ s.id = newId;
2870
2880
  });
2871
- return newStep;
2881
+ return {
2882
+ step: newStep,
2883
+ duplicatedIds
2884
+ };
2872
2885
  }
2873
2886
  }
2874
2887
 
@@ -2989,13 +3002,13 @@ class StateModifier {
2989
3002
  this.updateDependencies();
2990
3003
  return true;
2991
3004
  }
2992
- tryInsert(step, targetSequence, targetIndex) {
3005
+ tryInsert(step, targetSequence, targetIndex, details) {
2993
3006
  const canInsertStep = this.configuration.canInsertStep ? this.configuration.canInsertStep(step, targetSequence, targetIndex) : true;
2994
3007
  if (!canInsertStep) {
2995
3008
  return false;
2996
3009
  }
2997
3010
  SequenceModifier.insertStep(step, targetSequence, targetIndex);
2998
- this.state.notifyDefinitionChanged(exports.DefinitionChangeType.stepInserted, step.id);
3011
+ this.state.notifyDefinitionChanged(exports.DefinitionChangeType.stepInserted, step.id, details);
2999
3012
  if (!this.configuration.isAutoSelectDisabled && this.isSelectable(step, targetSequence)) {
3000
3013
  this.trySelectStepById(step.id);
3001
3014
  }
@@ -3031,8 +3044,10 @@ class StateModifier {
3031
3044
  tryDuplicate(step, parentSequence) {
3032
3045
  const duplicator = new StepDuplicator(this.uidGenerator, this.definitionWalker);
3033
3046
  const index = parentSequence.indexOf(step);
3034
- const newStep = duplicator.duplicate(step);
3035
- return this.tryInsert(newStep, parentSequence, index + 1);
3047
+ const result = duplicator.duplicate(step);
3048
+ return this.tryInsert(result.step, parentSequence, index + 1, {
3049
+ duplicatedStepIds: result.duplicatedIds
3050
+ });
3036
3051
  }
3037
3052
  replaceDefinition(definition) {
3038
3053
  if (!definition) {
@@ -3047,11 +3062,12 @@ class StateModifier {
3047
3062
  }
3048
3063
 
3049
3064
  class DesignerState {
3050
- constructor(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed) {
3065
+ constructor(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed, preferenceStorage) {
3051
3066
  this.definition = definition;
3052
3067
  this.isReadonly = isReadonly;
3053
3068
  this.isToolboxCollapsed = isToolboxCollapsed;
3054
3069
  this.isEditorCollapsed = isEditorCollapsed;
3070
+ this.preferenceStorage = preferenceStorage;
3055
3071
  this.onViewportChanged = new SimpleEvent();
3056
3072
  this.onSelectedStepIdChanged = new SimpleEvent();
3057
3073
  this.onStepUnselectionBlocked = new SimpleEvent();
@@ -3062,6 +3078,7 @@ class DesignerState {
3062
3078
  this.onDefinitionChanged = new SimpleEvent();
3063
3079
  this.onIsToolboxCollapsedChanged = new SimpleEvent();
3064
3080
  this.onIsEditorCollapsedChanged = new SimpleEvent();
3081
+ this.onPreferencesChanged = new SimpleEvent();
3065
3082
  this.viewport = {
3066
3083
  position: new Vector(0, 0),
3067
3084
  scale: 1
@@ -3092,8 +3109,16 @@ class DesignerState {
3092
3109
  this.definition = definition;
3093
3110
  this.notifyDefinitionChanged(exports.DefinitionChangeType.rootReplaced, null);
3094
3111
  }
3095
- notifyDefinitionChanged(changeType, stepId) {
3096
- this.onDefinitionChanged.forward({ changeType, stepId });
3112
+ notifyDefinitionChanged(changeType, stepId, details) {
3113
+ const event = {
3114
+ definition: this.definition,
3115
+ changeType,
3116
+ stepId
3117
+ };
3118
+ if (details) {
3119
+ Object.assign(event, details);
3120
+ }
3121
+ this.onDefinitionChanged.forward(event);
3097
3122
  }
3098
3123
  notifyStepUnselectionBlocked(stepId) {
3099
3124
  this.onStepUnselectionBlocked.forward(stepId);
@@ -3132,6 +3157,15 @@ class DesignerState {
3132
3157
  this.onIsEditorCollapsedChanged.forward(isCollapsed);
3133
3158
  }
3134
3159
  }
3160
+ setPreferences(changes, stepId) {
3161
+ for (const change of changes) {
3162
+ this.preferenceStorage.setItem(change.key, change.value);
3163
+ }
3164
+ this.onPreferencesChanged.forward({ changes, stepId });
3165
+ }
3166
+ getPreference(key) {
3167
+ return this.preferenceStorage.getItem(key);
3168
+ }
3135
3169
  }
3136
3170
 
3137
3171
  class HistoryController {
@@ -3285,22 +3319,22 @@ class DesignerContext {
3285
3319
  const isReadonly = Boolean(configuration.isReadonly);
3286
3320
  const isToolboxCollapsed = configuration.toolbox ? (_a = configuration.toolbox.isCollapsed) !== null && _a !== void 0 ? _a : layoutController.isMobile() : false;
3287
3321
  const isEditorCollapsed = configuration.editors ? (_b = configuration.editors.isCollapsed) !== null && _b !== void 0 ? _b : layoutController.isMobile() : false;
3322
+ const preferenceStorage = (_c = configuration.preferenceStorage) !== null && _c !== void 0 ? _c : new MemoryPreferenceStorage();
3288
3323
  const theme = configuration.theme || 'light';
3289
- const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
3324
+ const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed, preferenceStorage);
3290
3325
  const workspaceController = new WorkspaceControllerWrapper();
3291
3326
  const behaviorController = BehaviorController.create(configuration.shadowRoot);
3292
3327
  const stepExtensionResolver = StepExtensionResolver.create(services);
3293
3328
  const placeholderController = PlaceholderController.create(state, configuration.placeholder);
3294
- const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new sequentialWorkflowModel.DefinitionWalker();
3295
- const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
3296
- const uidGenerator = (_e = configuration.uidGenerator) !== null && _e !== void 0 ? _e : Uid.next;
3329
+ const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new sequentialWorkflowModel.DefinitionWalker();
3330
+ const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
3331
+ const uidGenerator = (_f = configuration.uidGenerator) !== null && _f !== void 0 ? _f : Uid.next;
3297
3332
  const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
3298
3333
  const customActionController = new CustomActionController(configuration, state, stateModifier);
3299
3334
  let historyController = undefined;
3300
3335
  if (configuration.undoStackSize) {
3301
3336
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
3302
3337
  }
3303
- const preferenceStorage = (_f = configuration.preferenceStorage) !== null && _f !== void 0 ? _f : new MemoryPreferenceStorage();
3304
3338
  const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services);
3305
3339
  return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3306
3340
  }
@@ -3574,16 +3608,13 @@ class PressingBehavior {
3574
3608
  }
3575
3609
  }
3576
3610
 
3577
- class RerenderStepPressingBehaviorHandler {
3611
+ class ChangePreferencesBehaviorHandler {
3578
3612
  constructor(command, designerContext) {
3579
3613
  this.command = command;
3580
3614
  this.designerContext = designerContext;
3581
3615
  }
3582
3616
  handle() {
3583
- if (this.command.beforeCallback) {
3584
- this.command.beforeCallback();
3585
- }
3586
- this.designerContext.workspaceController.updateRootComponent();
3617
+ this.designerContext.state.setPreferences(this.command.changes, this.command.step.id);
3587
3618
  }
3588
3619
  }
3589
3620
 
@@ -3619,8 +3650,8 @@ class ClickBehaviorResolver {
3619
3650
  switch (commandOrNull.type) {
3620
3651
  case exports.ClickCommandType.selectStep:
3621
3652
  return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
3622
- case exports.ClickCommandType.rerenderStep:
3623
- return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(commandOrNull, this.context));
3653
+ case exports.ClickCommandType.changePreferences:
3654
+ return PressingBehavior.create(element, new ChangePreferencesBehaviorHandler(commandOrNull, this.context));
3624
3655
  case exports.ClickCommandType.openFolder:
3625
3656
  return PressingBehavior.create(element, new OpenFolderPressingBehaviorHandler(commandOrNull, this.context));
3626
3657
  case exports.ClickCommandType.triggerCustomAction:
@@ -3931,6 +3962,7 @@ class Workspace {
3931
3962
  const workspace = new Workspace(view, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, api.workspace, designerContext.services);
3932
3963
  designerContext.setWorkspaceController(workspace);
3933
3964
  designerContext.state.onViewportChanged.subscribe(workspace.onViewportChanged);
3965
+ designerContext.state.onPreferencesChanged.subscribe(workspace.onPreferencesChanged);
3934
3966
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
3935
3967
  workspace.onStateChanged(r[0], r[1], r[2]);
3936
3968
  });
@@ -3953,11 +3985,25 @@ class Workspace {
3953
3985
  this.viewportApi = viewportApi;
3954
3986
  this.workspaceApi = workspaceApi;
3955
3987
  this.services = services;
3956
- this.onRendered = new SimpleEvent();
3988
+ this.onRootComponentUpdated = new SimpleEvent();
3957
3989
  this.isValid = false;
3958
3990
  this.initTimeout = null;
3959
3991
  this.selectedStepComponent = null;
3960
3992
  this.validationErrorBadgeIndex = null;
3993
+ this.updateRootComponent = () => {
3994
+ this.selectedStepComponent = null;
3995
+ const rootSequence = this.workspaceApi.getRootSequence();
3996
+ const parentPlaceIndicator = rootSequence.parentStep
3997
+ ? {
3998
+ sequence: rootSequence.parentStep.parentSequence,
3999
+ index: rootSequence.parentStep.index
4000
+ }
4001
+ : null;
4002
+ this.view.render(rootSequence.sequence, parentPlaceIndicator);
4003
+ this.trySelectStepComponent(this.state.selectedStepId);
4004
+ this.updateBadges();
4005
+ this.onRootComponentUpdated.forward();
4006
+ };
3961
4007
  this.onClick = (position, target, buttonIndex, altKey) => {
3962
4008
  const isPrimaryButton = buttonIndex === 0;
3963
4009
  const isMiddleButton = buttonIndex === 1;
@@ -3984,6 +4030,9 @@ class Workspace {
3984
4030
  this.onViewportChanged = (viewport) => {
3985
4031
  this.view.setPositionAndScale(viewport.position, viewport.scale);
3986
4032
  };
4033
+ this.onPreferencesChanged = () => {
4034
+ this.updateRootComponent();
4035
+ };
3987
4036
  }
3988
4037
  scheduleInit() {
3989
4038
  this.initTimeout = setTimeout(() => {
@@ -3992,20 +4041,6 @@ class Workspace {
3992
4041
  this.viewportApi.resetViewport();
3993
4042
  });
3994
4043
  }
3995
- updateRootComponent() {
3996
- this.selectedStepComponent = null;
3997
- const rootSequence = this.workspaceApi.getRootSequence();
3998
- const parentPlaceIndicator = rootSequence.parentStep
3999
- ? {
4000
- sequence: rootSequence.parentStep.parentSequence,
4001
- index: rootSequence.parentStep.index
4002
- }
4003
- : null;
4004
- this.view.render(rootSequence.sequence, parentPlaceIndicator);
4005
- this.trySelectStepComponent(this.state.selectedStepId);
4006
- this.updateBadges();
4007
- this.onRendered.forward();
4008
- }
4009
4044
  updateBadges() {
4010
4045
  const result = BadgesResultFactory.create(this.services);
4011
4046
  this.getRootComponent().updateBadges(result);
@@ -5034,11 +5069,12 @@ class Designer {
5034
5069
  const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
5035
5070
  const designerApi = DesignerApi.create(designerContext);
5036
5071
  const view = DesignerView.create(placeholder, designerContext, designerApi);
5037
- const designer = new Designer(view, designerContext.state, designerContext.stateModifier, designerContext.definitionWalker, designerContext.historyController, designerApi);
5038
- view.workspace.onRendered.first().then(designer.onReady.forward);
5072
+ const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
5073
+ view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.forward);
5074
+ view.workspace.onRootComponentUpdated.once().then(designer.onReady.forward);
5039
5075
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
5040
5076
  if (definition !== undefined) {
5041
- designer.onDefinitionChanged.forward(designerContext.state.definition);
5077
+ designer.onDefinitionChanged.forward(definition);
5042
5078
  }
5043
5079
  if (selectedStepId !== undefined) {
5044
5080
  designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
@@ -5048,12 +5084,12 @@ class Designer {
5048
5084
  designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.forward);
5049
5085
  designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.forward);
5050
5086
  designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.forward);
5087
+ designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.forward);
5051
5088
  return designer;
5052
5089
  }
5053
- constructor(view, state, stateModifier, walker, historyController, api) {
5090
+ constructor(view, state, walker, historyController, api) {
5054
5091
  this.view = view;
5055
5092
  this.state = state;
5056
- this.stateModifier = stateModifier;
5057
5093
  this.walker = walker;
5058
5094
  this.historyController = historyController;
5059
5095
  this.api = api;
@@ -5085,6 +5121,14 @@ class Designer {
5085
5121
  * @description Fires when the editor is collapsed or expanded.
5086
5122
  */
5087
5123
  this.onIsEditorCollapsedChanged = new SimpleEvent();
5124
+ /**
5125
+ * @description Fires when the root component and all its children are rerendered.
5126
+ */
5127
+ this.onRootComponentUpdated = new SimpleEvent();
5128
+ /**
5129
+ * @description Fires when any of the designer preferences has changed.
5130
+ */
5131
+ this.onPreferencesChanged = new SimpleEvent();
5088
5132
  }
5089
5133
  /**
5090
5134
  * @returns the current definition of the workflow.
@@ -5210,8 +5254,8 @@ class Designer {
5210
5254
  return __awaiter(this, void 0, void 0, function* () {
5211
5255
  this.getHistoryController().replaceDefinition(definition);
5212
5256
  yield Promise.all([
5213
- this.view.workspace.onRendered.first(),
5214
- this.onDefinitionChanged.first()
5257
+ this.view.workspace.onRootComponentUpdated.once(),
5258
+ this.onDefinitionChanged.once()
5215
5259
  ]);
5216
5260
  });
5217
5261
  }
package/lib/esm/index.js CHANGED
@@ -151,7 +151,7 @@ class SimpleEvent {
151
151
  count() {
152
152
  return this.listeners.length;
153
153
  }
154
- first() {
154
+ once() {
155
155
  return new Promise(resolve => {
156
156
  const handler = (value) => {
157
157
  this.unsubscribe(handler);
@@ -1333,7 +1333,7 @@ class DefaultSequenceComponent {
1333
1333
  var ClickCommandType;
1334
1334
  (function (ClickCommandType) {
1335
1335
  ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
1336
- ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
1336
+ ClickCommandType[ClickCommandType["changePreferences"] = 2] = "changePreferences";
1337
1337
  ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
1338
1338
  ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
1339
1339
  })(ClickCommandType || (ClickCommandType = {}));
@@ -2550,7 +2550,12 @@ class StepComponentViewContextFactory {
2550
2550
  createPlaceholderForGap: componentContext.services.placeholder.createForGap.bind(componentContext.services.placeholder),
2551
2551
  createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
2552
2552
  getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
2553
- setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
2553
+ createPreferenceChange: (key, value) => {
2554
+ return {
2555
+ key: preferenceKeyPrefix + key,
2556
+ value
2557
+ };
2558
+ }
2554
2559
  };
2555
2560
  }
2556
2561
  }
@@ -2863,11 +2868,19 @@ class StepDuplicator {
2863
2868
  }
2864
2869
  duplicate(step) {
2865
2870
  const newStep = ObjectCloner.deepClone(step);
2866
- newStep.id = this.uidGenerator();
2871
+ const duplicatedIds = [];
2872
+ const newId = this.uidGenerator();
2873
+ duplicatedIds.push([step.id, newId]);
2874
+ newStep.id = newId;
2867
2875
  this.definitionWalker.forEachChildren(newStep, s => {
2868
- s.id = this.uidGenerator();
2876
+ const newId = this.uidGenerator();
2877
+ duplicatedIds.push([s.id, newId]);
2878
+ s.id = newId;
2869
2879
  });
2870
- return newStep;
2880
+ return {
2881
+ step: newStep,
2882
+ duplicatedIds
2883
+ };
2871
2884
  }
2872
2885
  }
2873
2886
 
@@ -2988,13 +3001,13 @@ class StateModifier {
2988
3001
  this.updateDependencies();
2989
3002
  return true;
2990
3003
  }
2991
- tryInsert(step, targetSequence, targetIndex) {
3004
+ tryInsert(step, targetSequence, targetIndex, details) {
2992
3005
  const canInsertStep = this.configuration.canInsertStep ? this.configuration.canInsertStep(step, targetSequence, targetIndex) : true;
2993
3006
  if (!canInsertStep) {
2994
3007
  return false;
2995
3008
  }
2996
3009
  SequenceModifier.insertStep(step, targetSequence, targetIndex);
2997
- this.state.notifyDefinitionChanged(DefinitionChangeType.stepInserted, step.id);
3010
+ this.state.notifyDefinitionChanged(DefinitionChangeType.stepInserted, step.id, details);
2998
3011
  if (!this.configuration.isAutoSelectDisabled && this.isSelectable(step, targetSequence)) {
2999
3012
  this.trySelectStepById(step.id);
3000
3013
  }
@@ -3030,8 +3043,10 @@ class StateModifier {
3030
3043
  tryDuplicate(step, parentSequence) {
3031
3044
  const duplicator = new StepDuplicator(this.uidGenerator, this.definitionWalker);
3032
3045
  const index = parentSequence.indexOf(step);
3033
- const newStep = duplicator.duplicate(step);
3034
- return this.tryInsert(newStep, parentSequence, index + 1);
3046
+ const result = duplicator.duplicate(step);
3047
+ return this.tryInsert(result.step, parentSequence, index + 1, {
3048
+ duplicatedStepIds: result.duplicatedIds
3049
+ });
3035
3050
  }
3036
3051
  replaceDefinition(definition) {
3037
3052
  if (!definition) {
@@ -3046,11 +3061,12 @@ class StateModifier {
3046
3061
  }
3047
3062
 
3048
3063
  class DesignerState {
3049
- constructor(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed) {
3064
+ constructor(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed, preferenceStorage) {
3050
3065
  this.definition = definition;
3051
3066
  this.isReadonly = isReadonly;
3052
3067
  this.isToolboxCollapsed = isToolboxCollapsed;
3053
3068
  this.isEditorCollapsed = isEditorCollapsed;
3069
+ this.preferenceStorage = preferenceStorage;
3054
3070
  this.onViewportChanged = new SimpleEvent();
3055
3071
  this.onSelectedStepIdChanged = new SimpleEvent();
3056
3072
  this.onStepUnselectionBlocked = new SimpleEvent();
@@ -3061,6 +3077,7 @@ class DesignerState {
3061
3077
  this.onDefinitionChanged = new SimpleEvent();
3062
3078
  this.onIsToolboxCollapsedChanged = new SimpleEvent();
3063
3079
  this.onIsEditorCollapsedChanged = new SimpleEvent();
3080
+ this.onPreferencesChanged = new SimpleEvent();
3064
3081
  this.viewport = {
3065
3082
  position: new Vector(0, 0),
3066
3083
  scale: 1
@@ -3091,8 +3108,16 @@ class DesignerState {
3091
3108
  this.definition = definition;
3092
3109
  this.notifyDefinitionChanged(DefinitionChangeType.rootReplaced, null);
3093
3110
  }
3094
- notifyDefinitionChanged(changeType, stepId) {
3095
- this.onDefinitionChanged.forward({ changeType, stepId });
3111
+ notifyDefinitionChanged(changeType, stepId, details) {
3112
+ const event = {
3113
+ definition: this.definition,
3114
+ changeType,
3115
+ stepId
3116
+ };
3117
+ if (details) {
3118
+ Object.assign(event, details);
3119
+ }
3120
+ this.onDefinitionChanged.forward(event);
3096
3121
  }
3097
3122
  notifyStepUnselectionBlocked(stepId) {
3098
3123
  this.onStepUnselectionBlocked.forward(stepId);
@@ -3131,6 +3156,15 @@ class DesignerState {
3131
3156
  this.onIsEditorCollapsedChanged.forward(isCollapsed);
3132
3157
  }
3133
3158
  }
3159
+ setPreferences(changes, stepId) {
3160
+ for (const change of changes) {
3161
+ this.preferenceStorage.setItem(change.key, change.value);
3162
+ }
3163
+ this.onPreferencesChanged.forward({ changes, stepId });
3164
+ }
3165
+ getPreference(key) {
3166
+ return this.preferenceStorage.getItem(key);
3167
+ }
3134
3168
  }
3135
3169
 
3136
3170
  class HistoryController {
@@ -3284,22 +3318,22 @@ class DesignerContext {
3284
3318
  const isReadonly = Boolean(configuration.isReadonly);
3285
3319
  const isToolboxCollapsed = configuration.toolbox ? (_a = configuration.toolbox.isCollapsed) !== null && _a !== void 0 ? _a : layoutController.isMobile() : false;
3286
3320
  const isEditorCollapsed = configuration.editors ? (_b = configuration.editors.isCollapsed) !== null && _b !== void 0 ? _b : layoutController.isMobile() : false;
3321
+ const preferenceStorage = (_c = configuration.preferenceStorage) !== null && _c !== void 0 ? _c : new MemoryPreferenceStorage();
3287
3322
  const theme = configuration.theme || 'light';
3288
- const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
3323
+ const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed, preferenceStorage);
3289
3324
  const workspaceController = new WorkspaceControllerWrapper();
3290
3325
  const behaviorController = BehaviorController.create(configuration.shadowRoot);
3291
3326
  const stepExtensionResolver = StepExtensionResolver.create(services);
3292
3327
  const placeholderController = PlaceholderController.create(state, configuration.placeholder);
3293
- const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
3294
- const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
3295
- const uidGenerator = (_e = configuration.uidGenerator) !== null && _e !== void 0 ? _e : Uid.next;
3328
+ const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new DefinitionWalker();
3329
+ const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
3330
+ const uidGenerator = (_f = configuration.uidGenerator) !== null && _f !== void 0 ? _f : Uid.next;
3296
3331
  const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
3297
3332
  const customActionController = new CustomActionController(configuration, state, stateModifier);
3298
3333
  let historyController = undefined;
3299
3334
  if (configuration.undoStackSize) {
3300
3335
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
3301
3336
  }
3302
- const preferenceStorage = (_f = configuration.preferenceStorage) !== null && _f !== void 0 ? _f : new MemoryPreferenceStorage();
3303
3337
  const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services);
3304
3338
  return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3305
3339
  }
@@ -3573,16 +3607,13 @@ class PressingBehavior {
3573
3607
  }
3574
3608
  }
3575
3609
 
3576
- class RerenderStepPressingBehaviorHandler {
3610
+ class ChangePreferencesBehaviorHandler {
3577
3611
  constructor(command, designerContext) {
3578
3612
  this.command = command;
3579
3613
  this.designerContext = designerContext;
3580
3614
  }
3581
3615
  handle() {
3582
- if (this.command.beforeCallback) {
3583
- this.command.beforeCallback();
3584
- }
3585
- this.designerContext.workspaceController.updateRootComponent();
3616
+ this.designerContext.state.setPreferences(this.command.changes, this.command.step.id);
3586
3617
  }
3587
3618
  }
3588
3619
 
@@ -3618,8 +3649,8 @@ class ClickBehaviorResolver {
3618
3649
  switch (commandOrNull.type) {
3619
3650
  case ClickCommandType.selectStep:
3620
3651
  return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
3621
- case ClickCommandType.rerenderStep:
3622
- return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(commandOrNull, this.context));
3652
+ case ClickCommandType.changePreferences:
3653
+ return PressingBehavior.create(element, new ChangePreferencesBehaviorHandler(commandOrNull, this.context));
3623
3654
  case ClickCommandType.openFolder:
3624
3655
  return PressingBehavior.create(element, new OpenFolderPressingBehaviorHandler(commandOrNull, this.context));
3625
3656
  case ClickCommandType.triggerCustomAction:
@@ -3930,6 +3961,7 @@ class Workspace {
3930
3961
  const workspace = new Workspace(view, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, api.workspace, designerContext.services);
3931
3962
  designerContext.setWorkspaceController(workspace);
3932
3963
  designerContext.state.onViewportChanged.subscribe(workspace.onViewportChanged);
3964
+ designerContext.state.onPreferencesChanged.subscribe(workspace.onPreferencesChanged);
3933
3965
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
3934
3966
  workspace.onStateChanged(r[0], r[1], r[2]);
3935
3967
  });
@@ -3952,11 +3984,25 @@ class Workspace {
3952
3984
  this.viewportApi = viewportApi;
3953
3985
  this.workspaceApi = workspaceApi;
3954
3986
  this.services = services;
3955
- this.onRendered = new SimpleEvent();
3987
+ this.onRootComponentUpdated = new SimpleEvent();
3956
3988
  this.isValid = false;
3957
3989
  this.initTimeout = null;
3958
3990
  this.selectedStepComponent = null;
3959
3991
  this.validationErrorBadgeIndex = null;
3992
+ this.updateRootComponent = () => {
3993
+ this.selectedStepComponent = null;
3994
+ const rootSequence = this.workspaceApi.getRootSequence();
3995
+ const parentPlaceIndicator = rootSequence.parentStep
3996
+ ? {
3997
+ sequence: rootSequence.parentStep.parentSequence,
3998
+ index: rootSequence.parentStep.index
3999
+ }
4000
+ : null;
4001
+ this.view.render(rootSequence.sequence, parentPlaceIndicator);
4002
+ this.trySelectStepComponent(this.state.selectedStepId);
4003
+ this.updateBadges();
4004
+ this.onRootComponentUpdated.forward();
4005
+ };
3960
4006
  this.onClick = (position, target, buttonIndex, altKey) => {
3961
4007
  const isPrimaryButton = buttonIndex === 0;
3962
4008
  const isMiddleButton = buttonIndex === 1;
@@ -3983,6 +4029,9 @@ class Workspace {
3983
4029
  this.onViewportChanged = (viewport) => {
3984
4030
  this.view.setPositionAndScale(viewport.position, viewport.scale);
3985
4031
  };
4032
+ this.onPreferencesChanged = () => {
4033
+ this.updateRootComponent();
4034
+ };
3986
4035
  }
3987
4036
  scheduleInit() {
3988
4037
  this.initTimeout = setTimeout(() => {
@@ -3991,20 +4040,6 @@ class Workspace {
3991
4040
  this.viewportApi.resetViewport();
3992
4041
  });
3993
4042
  }
3994
- updateRootComponent() {
3995
- this.selectedStepComponent = null;
3996
- const rootSequence = this.workspaceApi.getRootSequence();
3997
- const parentPlaceIndicator = rootSequence.parentStep
3998
- ? {
3999
- sequence: rootSequence.parentStep.parentSequence,
4000
- index: rootSequence.parentStep.index
4001
- }
4002
- : null;
4003
- this.view.render(rootSequence.sequence, parentPlaceIndicator);
4004
- this.trySelectStepComponent(this.state.selectedStepId);
4005
- this.updateBadges();
4006
- this.onRendered.forward();
4007
- }
4008
4043
  updateBadges() {
4009
4044
  const result = BadgesResultFactory.create(this.services);
4010
4045
  this.getRootComponent().updateBadges(result);
@@ -5033,11 +5068,12 @@ class Designer {
5033
5068
  const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
5034
5069
  const designerApi = DesignerApi.create(designerContext);
5035
5070
  const view = DesignerView.create(placeholder, designerContext, designerApi);
5036
- const designer = new Designer(view, designerContext.state, designerContext.stateModifier, designerContext.definitionWalker, designerContext.historyController, designerApi);
5037
- view.workspace.onRendered.first().then(designer.onReady.forward);
5071
+ const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
5072
+ view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.forward);
5073
+ view.workspace.onRootComponentUpdated.once().then(designer.onReady.forward);
5038
5074
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
5039
5075
  if (definition !== undefined) {
5040
- designer.onDefinitionChanged.forward(designerContext.state.definition);
5076
+ designer.onDefinitionChanged.forward(definition);
5041
5077
  }
5042
5078
  if (selectedStepId !== undefined) {
5043
5079
  designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
@@ -5047,12 +5083,12 @@ class Designer {
5047
5083
  designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.forward);
5048
5084
  designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.forward);
5049
5085
  designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.forward);
5086
+ designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.forward);
5050
5087
  return designer;
5051
5088
  }
5052
- constructor(view, state, stateModifier, walker, historyController, api) {
5089
+ constructor(view, state, walker, historyController, api) {
5053
5090
  this.view = view;
5054
5091
  this.state = state;
5055
- this.stateModifier = stateModifier;
5056
5092
  this.walker = walker;
5057
5093
  this.historyController = historyController;
5058
5094
  this.api = api;
@@ -5084,6 +5120,14 @@ class Designer {
5084
5120
  * @description Fires when the editor is collapsed or expanded.
5085
5121
  */
5086
5122
  this.onIsEditorCollapsedChanged = new SimpleEvent();
5123
+ /**
5124
+ * @description Fires when the root component and all its children are rerendered.
5125
+ */
5126
+ this.onRootComponentUpdated = new SimpleEvent();
5127
+ /**
5128
+ * @description Fires when any of the designer preferences has changed.
5129
+ */
5130
+ this.onPreferencesChanged = new SimpleEvent();
5087
5131
  }
5088
5132
  /**
5089
5133
  * @returns the current definition of the workflow.
@@ -5209,8 +5253,8 @@ class Designer {
5209
5253
  return __awaiter(this, void 0, void 0, function* () {
5210
5254
  this.getHistoryController().replaceDefinition(definition);
5211
5255
  yield Promise.all([
5212
- this.view.workspace.onRendered.first(),
5213
- this.onDefinitionChanged.first()
5256
+ this.view.workspace.onRootComponentUpdated.once(),
5257
+ this.onDefinitionChanged.once()
5214
5258
  ]);
5215
5259
  });
5216
5260
  }