sequential-workflow-designer 0.18.3 → 0.18.5

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/esm/index.js CHANGED
@@ -1,94 +1,6 @@
1
1
  import { DefinitionWalker, StepChildrenType } from 'sequential-workflow-model';
2
2
  export * from 'sequential-workflow-model';
3
3
 
4
- class ControlBarApi {
5
- constructor(state, historyController, definitionModifier, viewportApi) {
6
- this.state = state;
7
- this.historyController = historyController;
8
- this.definitionModifier = definitionModifier;
9
- this.viewportApi = viewportApi;
10
- }
11
- /**
12
- * @deprecated Don't use this method
13
- */
14
- subscribe(handler) {
15
- // TODO: this should be refactored
16
- this.state.onIsReadonlyChanged.subscribe(handler);
17
- this.state.onSelectedStepIdChanged.subscribe(handler);
18
- this.state.onIsDragDisabledChanged.subscribe(handler);
19
- if (this.isUndoRedoSupported()) {
20
- this.state.onDefinitionChanged.subscribe(handler);
21
- }
22
- }
23
- resetViewport() {
24
- this.viewportApi.resetViewport();
25
- }
26
- zoomIn() {
27
- this.viewportApi.zoom(true);
28
- }
29
- zoomOut() {
30
- this.viewportApi.zoom(false);
31
- }
32
- isDragDisabled() {
33
- return this.state.isDragDisabled;
34
- }
35
- toggleIsDragDisabled() {
36
- this.state.toggleIsDragDisabled();
37
- }
38
- isUndoRedoSupported() {
39
- return !!this.historyController;
40
- }
41
- tryUndo() {
42
- if (this.canUndo() && this.historyController) {
43
- this.historyController.undo();
44
- return true;
45
- }
46
- return false;
47
- }
48
- canUndo() {
49
- return !!this.historyController && this.historyController.canUndo() && !this.state.isReadonly && !this.state.isDragging;
50
- }
51
- tryRedo() {
52
- if (this.canRedo() && this.historyController) {
53
- this.historyController.redo();
54
- return true;
55
- }
56
- return false;
57
- }
58
- canRedo() {
59
- return !!this.historyController && this.historyController.canRedo() && !this.state.isReadonly && !this.state.isDragging;
60
- }
61
- tryDelete() {
62
- if (this.canDelete() && this.state.selectedStepId) {
63
- this.definitionModifier.tryDelete(this.state.selectedStepId);
64
- return true;
65
- }
66
- return false;
67
- }
68
- canDelete() {
69
- return (!!this.state.selectedStepId &&
70
- !this.state.isReadonly &&
71
- !this.state.isDragging &&
72
- this.definitionModifier.isDeletable(this.state.selectedStepId));
73
- }
74
- }
75
-
76
- var KeyboardAction;
77
- (function (KeyboardAction) {
78
- KeyboardAction["delete"] = "delete";
79
- })(KeyboardAction || (KeyboardAction = {}));
80
- var DefinitionChangeType;
81
- (function (DefinitionChangeType) {
82
- DefinitionChangeType[DefinitionChangeType["stepNameChanged"] = 1] = "stepNameChanged";
83
- DefinitionChangeType[DefinitionChangeType["stepPropertyChanged"] = 2] = "stepPropertyChanged";
84
- DefinitionChangeType[DefinitionChangeType["stepChildrenChanged"] = 3] = "stepChildrenChanged";
85
- DefinitionChangeType[DefinitionChangeType["stepDeleted"] = 4] = "stepDeleted";
86
- DefinitionChangeType[DefinitionChangeType["stepMoved"] = 5] = "stepMoved";
87
- DefinitionChangeType[DefinitionChangeType["stepInserted"] = 6] = "stepInserted";
88
- DefinitionChangeType[DefinitionChangeType["rootPropertyChanged"] = 7] = "rootPropertyChanged";
89
- DefinitionChangeType[DefinitionChangeType["rootReplaced"] = 8] = "rootReplaced";
90
- })(DefinitionChangeType || (DefinitionChangeType = {}));
91
-
92
4
  class Dom {
93
5
  static svg(name, attributes) {
94
6
  const element = document.createElementNS('http://www.w3.org/2000/svg', name);
@@ -218,6 +130,11 @@ class Uid {
218
130
  class SimpleEvent {
219
131
  constructor() {
220
132
  this.listeners = [];
133
+ this.forward = (value) => {
134
+ if (this.listeners.length > 0) {
135
+ this.listeners.forEach(listener => listener(value));
136
+ }
137
+ };
221
138
  }
222
139
  subscribe(listener) {
223
140
  this.listeners.push(listener);
@@ -231,14 +148,18 @@ class SimpleEvent {
231
148
  throw new Error('Unknown listener');
232
149
  }
233
150
  }
234
- forward(value) {
235
- if (this.listeners.length > 0) {
236
- this.listeners.forEach(listener => listener(value));
237
- }
238
- }
239
151
  count() {
240
152
  return this.listeners.length;
241
153
  }
154
+ first() {
155
+ return new Promise(resolve => {
156
+ const handler = (value) => {
157
+ this.unsubscribe(handler);
158
+ resolve(value);
159
+ };
160
+ this.subscribe(handler);
161
+ });
162
+ }
242
163
  }
243
164
 
244
165
  function race(timeout, a, b, c) {
@@ -271,6 +192,99 @@ function race(timeout, a, b, c) {
271
192
  return result;
272
193
  }
273
194
 
195
+ class ControlBarApi {
196
+ static create(state, historyController, definitionModifier, viewportApi) {
197
+ const api = new ControlBarApi(state, historyController, definitionModifier, viewportApi);
198
+ state.onIsReadonlyChanged.subscribe(api.onStateChanged.forward);
199
+ state.onSelectedStepIdChanged.subscribe(api.onStateChanged.forward);
200
+ state.onIsDragDisabledChanged.subscribe(api.onStateChanged.forward);
201
+ if (api.isUndoRedoSupported()) {
202
+ state.onDefinitionChanged.subscribe(api.onStateChanged.forward);
203
+ }
204
+ return api;
205
+ }
206
+ constructor(state, historyController, definitionModifier, viewportApi) {
207
+ this.state = state;
208
+ this.historyController = historyController;
209
+ this.definitionModifier = definitionModifier;
210
+ this.viewportApi = viewportApi;
211
+ this.onStateChanged = new SimpleEvent();
212
+ }
213
+ /**
214
+ * @deprecated Don't use this method
215
+ */
216
+ subscribe(handler) {
217
+ this.onStateChanged.subscribe(handler);
218
+ }
219
+ resetViewport() {
220
+ this.viewportApi.resetViewport();
221
+ }
222
+ zoomIn() {
223
+ this.viewportApi.zoom(true);
224
+ }
225
+ zoomOut() {
226
+ this.viewportApi.zoom(false);
227
+ }
228
+ isDragDisabled() {
229
+ return this.state.isDragDisabled;
230
+ }
231
+ toggleIsDragDisabled() {
232
+ this.state.toggleIsDragDisabled();
233
+ }
234
+ isUndoRedoSupported() {
235
+ return !!this.historyController;
236
+ }
237
+ tryUndo() {
238
+ if (this.canUndo() && this.historyController) {
239
+ this.historyController.undo();
240
+ return true;
241
+ }
242
+ return false;
243
+ }
244
+ canUndo() {
245
+ return !!this.historyController && this.historyController.canUndo() && !this.state.isReadonly && !this.state.isDragging;
246
+ }
247
+ tryRedo() {
248
+ if (this.canRedo() && this.historyController) {
249
+ this.historyController.redo();
250
+ return true;
251
+ }
252
+ return false;
253
+ }
254
+ canRedo() {
255
+ return !!this.historyController && this.historyController.canRedo() && !this.state.isReadonly && !this.state.isDragging;
256
+ }
257
+ tryDelete() {
258
+ if (this.canDelete() && this.state.selectedStepId) {
259
+ this.definitionModifier.tryDelete(this.state.selectedStepId);
260
+ return true;
261
+ }
262
+ return false;
263
+ }
264
+ canDelete() {
265
+ return (!!this.state.selectedStepId &&
266
+ !this.state.isReadonly &&
267
+ !this.state.isDragging &&
268
+ this.definitionModifier.isDeletable(this.state.selectedStepId));
269
+ }
270
+ }
271
+
272
+ var KeyboardAction;
273
+ (function (KeyboardAction) {
274
+ KeyboardAction["delete"] = "delete";
275
+ })(KeyboardAction || (KeyboardAction = {}));
276
+ var DefinitionChangeType;
277
+ (function (DefinitionChangeType) {
278
+ DefinitionChangeType[DefinitionChangeType["stepNameChanged"] = 1] = "stepNameChanged";
279
+ DefinitionChangeType[DefinitionChangeType["stepPropertyChanged"] = 2] = "stepPropertyChanged";
280
+ DefinitionChangeType[DefinitionChangeType["stepChildrenChanged"] = 3] = "stepChildrenChanged";
281
+ DefinitionChangeType[DefinitionChangeType["stepDeleted"] = 4] = "stepDeleted";
282
+ DefinitionChangeType[DefinitionChangeType["stepMoved"] = 5] = "stepMoved";
283
+ DefinitionChangeType[DefinitionChangeType["stepInserted"] = 6] = "stepInserted";
284
+ DefinitionChangeType[DefinitionChangeType["rootPropertyChanged"] = 7] = "rootPropertyChanged";
285
+ DefinitionChangeType[DefinitionChangeType["rootReplaced"] = 8] = "rootReplaced";
286
+ })(DefinitionChangeType || (DefinitionChangeType = {}));
287
+
274
288
  class EditorRenderer {
275
289
  static create(state, definitionWalker, handler) {
276
290
  const raceEvent = race(0, state.onDefinitionChanged, state.onSelectedStepIdChanged, state.onIsReadonlyChanged);
@@ -371,13 +385,13 @@ class PathBarApi {
371
385
  constructor(state, definitionWalker) {
372
386
  this.state = state;
373
387
  this.definitionWalker = definitionWalker;
388
+ this.onStateChanged = race(0, this.state.onFolderPathChanged, this.state.onDefinitionChanged);
374
389
  }
375
390
  /**
376
391
  * @deprecated Don't use this method
377
392
  */
378
393
  subscribe(handler) {
379
- // TODO: this should be refactored
380
- race(0, this.state.onFolderPathChanged, this.state.onDefinitionChanged).subscribe(handler);
394
+ this.onStateChanged.subscribe(handler);
381
395
  }
382
396
  setFolderPath(path) {
383
397
  this.state.setFolderPath(path);
@@ -697,7 +711,7 @@ class DesignerApi {
697
711
  const viewportController = context.services.viewportController.create(workspace);
698
712
  const viewport = new ViewportApi(context.workspaceController, viewportController);
699
713
  const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.configuration.toolbox);
700
- return new DesignerApi(new ControlBarApi(context.state, context.historyController, context.definitionModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.definitionModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker));
714
+ return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.definitionModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.definitionModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker));
701
715
  }
702
716
  constructor(controlBar, toolbox, editor, workspace, viewport, pathBar) {
703
717
  this.controlBar = controlBar;
@@ -2257,11 +2271,11 @@ class HistoryController {
2257
2271
  };
2258
2272
  const controller = new HistoryController(stack, state, definitionModifier, configuration.undoStackSize);
2259
2273
  if (!initialStack) {
2260
- controller.remember(DefinitionChangeType.rootReplaced, null);
2274
+ controller.rememberCurrent(DefinitionChangeType.rootReplaced, null);
2261
2275
  }
2262
2276
  state.onDefinitionChanged.subscribe(event => {
2263
2277
  if (event.changeType !== DefinitionChangeType.rootReplaced) {
2264
- controller.remember(event.changeType, event.stepId);
2278
+ controller.rememberCurrent(event.changeType, event.stepId);
2265
2279
  }
2266
2280
  });
2267
2281
  return controller;
@@ -2289,8 +2303,18 @@ class HistoryController {
2289
2303
  dump() {
2290
2304
  return Object.assign({}, this.stack);
2291
2305
  }
2292
- remember(changeType, stepId) {
2293
- const definition = ObjectCloner.deepClone(this.state.definition);
2306
+ replaceDefinition(definition) {
2307
+ if (definition == this.state.definition) {
2308
+ throw new Error('Cannot use the same instance of definition');
2309
+ }
2310
+ this.remember(definition, DefinitionChangeType.rootReplaced, null);
2311
+ this.commit();
2312
+ }
2313
+ rememberCurrent(changeType, stepId) {
2314
+ this.remember(this.state.definition, changeType, stepId);
2315
+ }
2316
+ remember(sourceDefinition, changeType, stepId) {
2317
+ const definition = ObjectCloner.deepClone(sourceDefinition);
2294
2318
  if (this.stack.items.length > 0 && this.stack.index === this.stack.items.length) {
2295
2319
  const lastItem = this.stack.items[this.stack.items.length - 1];
2296
2320
  if (areItemsEqual(lastItem, changeType, stepId)) {
@@ -2315,7 +2339,7 @@ class HistoryController {
2315
2339
  }
2316
2340
  }
2317
2341
  function areItemsEqual(item, changeType, stepId) {
2318
- return item.changeType === changeType && item.stepId === stepId;
2342
+ return changeType !== DefinitionChangeType.rootReplaced && item.changeType === changeType && item.stepId === stepId;
2319
2343
  }
2320
2344
 
2321
2345
  class LayoutController {
@@ -2406,6 +2430,31 @@ class DesignerContext {
2406
2430
  }
2407
2431
  }
2408
2432
 
2433
+ /******************************************************************************
2434
+ Copyright (c) Microsoft Corporation.
2435
+
2436
+ Permission to use, copy, modify, and/or distribute this software for any
2437
+ purpose with or without fee is hereby granted.
2438
+
2439
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2440
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2441
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2442
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2443
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2444
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2445
+ PERFORMANCE OF THIS SOFTWARE.
2446
+ ***************************************************************************** */
2447
+
2448
+ function __awaiter(thisArg, _arguments, P, generator) {
2449
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2450
+ return new (P || (P = Promise))(function (resolve, reject) {
2451
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2452
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2453
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2454
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2455
+ });
2456
+ }
2457
+
2409
2458
  function isElementAttached(element) {
2410
2459
  return !(document.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2411
2460
  }
@@ -2860,7 +2909,6 @@ class Workspace {
2860
2909
  setTimeout(() => {
2861
2910
  workspace.updateRootComponent();
2862
2911
  api.viewport.resetViewport();
2863
- workspace.onReady.forward();
2864
2912
  });
2865
2913
  designerContext.setWorkspaceController(workspace);
2866
2914
  designerContext.state.onViewportChanged.subscribe(vp => workspace.onViewportChanged(vp));
@@ -2883,7 +2931,7 @@ class Workspace {
2883
2931
  this.clickBehaviorResolver = clickBehaviorResolver;
2884
2932
  this.viewportApi = viewportApi;
2885
2933
  this.services = services;
2886
- this.onReady = new SimpleEvent();
2934
+ this.onRendered = new SimpleEvent();
2887
2935
  this.isValid = false;
2888
2936
  this.selectedStepComponent = null;
2889
2937
  this.validationErrorBadgeIndex = null;
@@ -2912,6 +2960,7 @@ class Workspace {
2912
2960
  this.view.render(sequence, parentSequencePlaceIndicator);
2913
2961
  this.trySelectStepComponent(this.state.selectedStepId);
2914
2962
  this.updateBadges();
2963
+ this.onRendered.forward();
2915
2964
  }
2916
2965
  updateBadges() {
2917
2966
  const result = BadgesResultFactory.create(this.services);
@@ -3207,7 +3256,7 @@ class ControlBar {
3207
3256
  view.bindZoomOutButtonClick(() => bar.onZoomOutButtonClicked());
3208
3257
  view.bindDisableDragButtonClick(() => bar.onMoveButtonClicked());
3209
3258
  view.bindDeleteButtonClick(() => bar.onDeleteButtonClicked());
3210
- api.controlBar.subscribe(() => bar.refreshButtons());
3259
+ api.controlBar.onStateChanged.subscribe(() => bar.refreshButtons());
3211
3260
  if (isUndoRedoSupported) {
3212
3261
  view.bindUndoButtonClick(() => bar.onUndoButtonClicked());
3213
3262
  view.bindRedoButtonClick(() => bar.onRedoButtonClicked());
@@ -4162,7 +4211,7 @@ class Designer {
4162
4211
  const designerApi = DesignerApi.create(designerContext);
4163
4212
  const view = DesignerView.create(placeholder, designerContext, designerApi);
4164
4213
  const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
4165
- view.workspace.onReady.subscribe(() => designer.onReady.forward());
4214
+ view.workspace.onRendered.first().then(designer.onReady.forward);
4166
4215
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
4167
4216
  if (definition !== undefined) {
4168
4217
  designer.onDefinitionChanged.forward(designerContext.state.definition);
@@ -4171,15 +4220,9 @@ class Designer {
4171
4220
  designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
4172
4221
  }
4173
4222
  });
4174
- designerContext.state.onViewportChanged.subscribe(viewPort => {
4175
- designer.onViewportChanged.forward(viewPort);
4176
- });
4177
- designerContext.state.onIsToolboxCollapsedChanged.subscribe(isCollapsed => {
4178
- designer.onIsToolboxCollapsedChanged.forward(isCollapsed);
4179
- });
4180
- designerContext.state.onIsEditorCollapsedChanged.subscribe(isCollapsed => {
4181
- designer.onIsEditorCollapsedChanged.forward(isCollapsed);
4182
- });
4223
+ designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.forward);
4224
+ designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.forward);
4225
+ designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.forward);
4183
4226
  return designer;
4184
4227
  }
4185
4228
  constructor(view, state, walker, historyController, api) {
@@ -4320,10 +4363,20 @@ class Designer {
4320
4363
  * @description Dump the undo stack.
4321
4364
  */
4322
4365
  dumpUndoStack() {
4323
- if (!this.historyController) {
4324
- throw new Error('Undo feature is not activated');
4325
- }
4326
- return this.historyController.dump();
4366
+ return this.getHistoryController().dump();
4367
+ }
4368
+ /**
4369
+ * Replaces the current definition with a new one and adds the previous definition to the undo stack.
4370
+ * @param definition A new definition.
4371
+ */
4372
+ replaceDefinition(definition) {
4373
+ return __awaiter(this, void 0, void 0, function* () {
4374
+ this.getHistoryController().replaceDefinition(definition);
4375
+ yield Promise.all([
4376
+ this.view.workspace.onRendered.first(),
4377
+ this.onDefinitionChanged.first()
4378
+ ]);
4379
+ });
4327
4380
  }
4328
4381
  /**
4329
4382
  * @param needle A step, a sequence or a step id.
@@ -4344,6 +4397,12 @@ class Designer {
4344
4397
  destroy() {
4345
4398
  this.view.destroy();
4346
4399
  }
4400
+ getHistoryController() {
4401
+ if (!this.historyController) {
4402
+ throw new Error('Undo feature is not activated');
4403
+ }
4404
+ return this.historyController;
4405
+ }
4347
4406
  }
4348
4407
 
4349
4408
  class LineGridDesignerExtension {
package/lib/index.d.ts CHANGED
@@ -1,6 +1,73 @@
1
1
  import { Step, BranchedStep, SequentialStep, Definition, Sequence, ComponentType, DefinitionWalker, StepOrName } from 'sequential-workflow-model';
2
2
  export * from 'sequential-workflow-model';
3
3
 
4
+ declare class Icons {
5
+ static folderIn: string;
6
+ static folderOut: string;
7
+ static center: string;
8
+ static zoomIn: string;
9
+ static zoomOut: string;
10
+ static undo: string;
11
+ static redo: string;
12
+ static move: string;
13
+ static delete: string;
14
+ static folderUp: string;
15
+ static close: string;
16
+ static options: string;
17
+ static expand: string;
18
+ static alert: string;
19
+ static play: string;
20
+ static stop: string;
21
+ static folder: string;
22
+ static appendPath(parent: SVGElement, pathClassName: string, d: string, size: number): SVGGElement;
23
+ static createSvg(className: string, d: string): SVGElement;
24
+ }
25
+
26
+ declare class ObjectCloner {
27
+ static deepClone<T>(instance: T): T;
28
+ }
29
+
30
+ interface Attributes {
31
+ [name: string]: string | number;
32
+ }
33
+ declare class Dom {
34
+ static svg<K extends keyof SVGElementTagNameMap>(name: K, attributes?: Attributes): SVGElementTagNameMap[K];
35
+ static translate(element: SVGElement, x: number, y: number): void;
36
+ static attrs(element: Element, attributes: Attributes): void;
37
+ static element<T extends keyof HTMLElementTagNameMap>(name: T, attributes?: Attributes): HTMLElementTagNameMap[T];
38
+ static toggleClass(element: Element, isEnabled: boolean, className: string): void;
39
+ }
40
+
41
+ declare class Vector {
42
+ readonly x: number;
43
+ readonly y: number;
44
+ constructor(x: number, y: number);
45
+ add(v: Vector): Vector;
46
+ subtract(v: Vector): Vector;
47
+ multiplyByScalar(s: number): Vector;
48
+ divideByScalar(s: number): Vector;
49
+ round(): Vector;
50
+ distance(): number;
51
+ }
52
+
53
+ declare function getAbsolutePosition(element: Element): Vector;
54
+
55
+ declare class Uid {
56
+ static next(): string;
57
+ }
58
+
59
+ declare class SimpleEvent<T> {
60
+ private readonly listeners;
61
+ subscribe(listener: SimpleEventListener<T>): void;
62
+ unsubscribe(listener: SimpleEventListener<T>): void;
63
+ readonly forward: (value: T) => void;
64
+ count(): number;
65
+ first(): Promise<T>;
66
+ }
67
+ type SimpleEventListener<T> = (value: T) => void;
68
+
69
+ declare function race<A, B, C>(timeout: number, a: SimpleEvent<A>, b: SimpleEvent<B>, c?: SimpleEvent<C>): SimpleEvent<[A?, B?, C?]>;
70
+
4
71
  /**
5
72
  * @deprecated Use {@link Step} instead.
6
73
  */
@@ -20,18 +87,6 @@ interface ContainerStep extends SequentialStep {
20
87
  componentType: 'container';
21
88
  }
22
89
 
23
- declare class Vector {
24
- readonly x: number;
25
- readonly y: number;
26
- constructor(x: number, y: number);
27
- add(v: Vector): Vector;
28
- subtract(v: Vector): Vector;
29
- multiplyByScalar(s: number): Vector;
30
- divideByScalar(s: number): Vector;
31
- round(): Vector;
32
- distance(): number;
33
- }
34
-
35
90
  interface Behavior {
36
91
  onStart(position: Vector): void;
37
92
  onMove(delta: Vector): Behavior | void;
@@ -50,15 +105,6 @@ declare class BehaviorController {
50
105
  private stop;
51
106
  }
52
107
 
53
- declare class SimpleEvent<T> {
54
- private readonly listeners;
55
- subscribe(listener: SimpleEventListener<T>): void;
56
- unsubscribe(listener: SimpleEventListener<T>): void;
57
- forward(value: T): void;
58
- count(): number;
59
- }
60
- type SimpleEventListener<T> = (value: T) => void;
61
-
62
108
  interface DefinitionChangedEvent {
63
109
  changeType: DefinitionChangeType;
64
110
  stepId: string | null;
@@ -262,6 +308,8 @@ declare class HistoryController {
262
308
  canRedo(): boolean;
263
309
  redo(): void;
264
310
  dump(): UndoStack;
311
+ replaceDefinition(definition: Definition): void;
312
+ private rememberCurrent;
265
313
  private remember;
266
314
  private commit;
267
315
  }
@@ -272,51 +320,6 @@ declare class LayoutController {
272
320
  isMobile(): boolean;
273
321
  }
274
322
 
275
- declare class Icons {
276
- static folderIn: string;
277
- static folderOut: string;
278
- static center: string;
279
- static zoomIn: string;
280
- static zoomOut: string;
281
- static undo: string;
282
- static redo: string;
283
- static move: string;
284
- static delete: string;
285
- static folderUp: string;
286
- static close: string;
287
- static options: string;
288
- static expand: string;
289
- static alert: string;
290
- static play: string;
291
- static stop: string;
292
- static folder: string;
293
- static appendPath(parent: SVGElement, pathClassName: string, d: string, size: number): SVGGElement;
294
- static createSvg(className: string, d: string): SVGElement;
295
- }
296
-
297
- declare class ObjectCloner {
298
- static deepClone<T>(instance: T): T;
299
- }
300
-
301
- interface Attributes {
302
- [name: string]: string | number;
303
- }
304
- declare class Dom {
305
- static svg<K extends keyof SVGElementTagNameMap>(name: K, attributes?: Attributes): SVGElementTagNameMap[K];
306
- static translate(element: SVGElement, x: number, y: number): void;
307
- static attrs(element: Element, attributes: Attributes): void;
308
- static element<T extends keyof HTMLElementTagNameMap>(name: T, attributes?: Attributes): HTMLElementTagNameMap[T];
309
- static toggleClass(element: Element, isEnabled: boolean, className: string): void;
310
- }
311
-
312
- declare function getAbsolutePosition(element: Element): Vector;
313
-
314
- declare class Uid {
315
- static next(): string;
316
- }
317
-
318
- declare function race<A, B, C>(timeout: number, a: SimpleEvent<A>, b: SimpleEvent<B>, c?: SimpleEvent<C>): SimpleEvent<[A?, B?, C?]>;
319
-
320
323
  interface WorkspaceController {
321
324
  getPlaceholders(): Placeholder[];
322
325
  getComponentByStepId(stepId: string): StepComponent;
@@ -392,6 +395,7 @@ declare class PathBarApi {
392
395
  private readonly state;
393
396
  private readonly definitionWalker;
394
397
  constructor(state: DesignerState, definitionWalker: DefinitionWalker);
398
+ readonly onStateChanged: SimpleEvent<[(string[] | undefined)?, (DefinitionChangedEvent | undefined)?, unknown?]>;
395
399
  /**
396
400
  * @deprecated Don't use this method
397
401
  */
@@ -1001,7 +1005,9 @@ declare class ControlBarApi {
1001
1005
  private readonly historyController;
1002
1006
  private readonly definitionModifier;
1003
1007
  private readonly viewportApi;
1004
- constructor(state: DesignerState, historyController: HistoryController | undefined, definitionModifier: DefinitionModifier, viewportApi: ViewportApi);
1008
+ static create(state: DesignerState, historyController: HistoryController | undefined, definitionModifier: DefinitionModifier, viewportApi: ViewportApi): ControlBarApi;
1009
+ private constructor();
1010
+ readonly onStateChanged: SimpleEvent<unknown>;
1005
1011
  /**
1006
1012
  * @deprecated Don't use this method
1007
1013
  */
@@ -1140,6 +1146,11 @@ declare class Designer<TDefinition extends Definition = Definition> {
1140
1146
  * @description Dump the undo stack.
1141
1147
  */
1142
1148
  dumpUndoStack(): UndoStack;
1149
+ /**
1150
+ * Replaces the current definition with a new one and adds the previous definition to the undo stack.
1151
+ * @param definition A new definition.
1152
+ */
1153
+ replaceDefinition(definition: TDefinition): Promise<void>;
1143
1154
  /**
1144
1155
  * @param needle A step, a sequence or a step id.
1145
1156
  * @returns parent steps and branch names.
@@ -1153,6 +1164,7 @@ declare class Designer<TDefinition extends Definition = Definition> {
1153
1164
  * @description Destroys the designer and deletes all nodes from the placeholder.
1154
1165
  */
1155
1166
  destroy(): void;
1167
+ private getHistoryController;
1156
1168
  }
1157
1169
 
1158
1170
  declare class LineGrid implements Grid {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sequential-workflow-designer",
3
3
  "description": "Customizable no-code component for building flow-based programming applications.",
4
- "version": "0.18.3",
4
+ "version": "0.18.5",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",
@@ -33,6 +33,7 @@
33
33
  z-index: 20;
34
34
  box-sizing: border-box;
35
35
  width: 130px;
36
+ -webkit-user-select: none;
36
37
  user-select: none;
37
38
  }
38
39
  .sqd-toolbox-header {
@@ -222,6 +223,7 @@
222
223
  flex: 1;
223
224
  position: relative;
224
225
  display: block;
226
+ -webkit-user-select: none;
225
227
  user-select: none;
226
228
  }
227
229
  .sqd-workspace-canvas {