sequential-workflow-designer 0.37.3 → 0.38.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/README.md CHANGED
@@ -107,10 +107,10 @@ Add the below code to your head section in HTML document.
107
107
  ```html
108
108
  <head>
109
109
  ...
110
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.3/css/designer.css" rel="stylesheet" />
111
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.3/css/designer-light.css" rel="stylesheet" />
112
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.3/css/designer-dark.css" rel="stylesheet" />
113
- <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.3/dist/index.umd.js"></script>
110
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.38.0/css/designer.css" rel="stylesheet" />
111
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.38.0/css/designer-light.css" rel="stylesheet" />
112
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.38.0/css/designer-dark.css" rel="stylesheet" />
113
+ <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.38.0/dist/index.umd.js"></script>
114
114
  </head>
115
115
  ```
116
116
 
package/dist/index.umd.js CHANGED
@@ -16,10 +16,11 @@
16
16
  element.setAttribute('transform', `translate(${x}, ${y})`);
17
17
  }
18
18
  static attrs(element, attributes) {
19
- Object.keys(attributes).forEach(name => {
19
+ const names = Object.keys(attributes);
20
+ for (const name in names) {
20
21
  const value = attributes[name];
21
22
  element.setAttribute(name, typeof value === 'string' ? value : value.toString());
22
- });
23
+ }
23
24
  }
24
25
  static element(name, attributes) {
25
26
  const element = document.createElement(name);
@@ -133,9 +134,9 @@
133
134
  class SimpleEvent {
134
135
  constructor() {
135
136
  this.listeners = [];
136
- this.forward = (value) => {
137
- if (this.listeners.length > 0) {
138
- this.listeners.forEach(listener => listener(value));
137
+ this.emit = (value) => {
138
+ for (const listener of this.listeners) {
139
+ listener(value);
139
140
  }
140
141
  };
141
142
  }
@@ -169,14 +170,14 @@
169
170
  const value = [undefined, undefined, undefined, undefined];
170
171
  const result = new SimpleEvent();
171
172
  let scheduled = false;
172
- function forward() {
173
+ function emit() {
173
174
  if (scheduled) {
174
175
  return;
175
176
  }
176
177
  scheduled = true;
177
178
  setTimeout(() => {
178
179
  try {
179
- result.forward(value);
180
+ result.emit(value);
180
181
  }
181
182
  finally {
182
183
  scheduled = false;
@@ -187,7 +188,7 @@
187
188
  function subscribe(event, index) {
188
189
  event.subscribe(v => {
189
190
  value[index] = v;
190
- forward();
191
+ emit();
191
192
  });
192
193
  }
193
194
  subscribe(a, 0);
@@ -204,7 +205,7 @@
204
205
  class ControlBarApi {
205
206
  static create(state, historyController, stateModifier) {
206
207
  const api = new ControlBarApi(state, historyController, stateModifier);
207
- race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.forward);
208
+ race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.emit);
208
209
  return api;
209
210
  }
210
211
  constructor(state, historyController, stateModifier) {
@@ -1340,7 +1341,7 @@
1340
1341
  }
1341
1342
 
1342
1343
  class LabelView {
1343
- static create(parent, y, cfg, text, theme) {
1344
+ static create(parent, y, cfg, text, theme, textWidthMeasurer) {
1344
1345
  const g = Dom.svg('g', {
1345
1346
  class: `sqd-label sqd-label-${theme}`
1346
1347
  });
@@ -1351,7 +1352,8 @@
1351
1352
  });
1352
1353
  nameText.textContent = text;
1353
1354
  g.appendChild(nameText);
1354
- const width = Math.max(nameText.getBBox().width + cfg.paddingX * 2, cfg.minWidth);
1355
+ const nameWidth = textWidthMeasurer(nameText);
1356
+ const width = Math.max(nameWidth + cfg.paddingX * 2, cfg.minWidth);
1355
1357
  const nameRect = Dom.svg('rect', {
1356
1358
  class: 'sqd-label-rect',
1357
1359
  width: width,
@@ -1407,7 +1409,9 @@
1407
1409
  const { sequence } = sequenceContext;
1408
1410
  const g = Dom.svg('g');
1409
1411
  parent.appendChild(g);
1410
- const components = [];
1412
+ const components = new Array(sequence.length);
1413
+ let restWidth = 0;
1414
+ let joinX = 0;
1411
1415
  for (let index = 0; index < sequence.length; index++) {
1412
1416
  const stepContext = {
1413
1417
  parentSequence: sequenceContext.sequence,
@@ -1418,13 +1422,13 @@
1418
1422
  isOutputConnected: index === sequence.length - 1 ? sequenceContext.isOutputConnected : true,
1419
1423
  isPreview: sequenceContext.isPreview
1420
1424
  };
1421
- components[index] = componentContext.stepComponentFactory.create(g, stepContext, componentContext);
1425
+ const component = componentContext.stepComponentFactory.create(g, stepContext, componentContext);
1426
+ components[index] = component;
1427
+ restWidth = Math.max(restWidth, component.view.width - component.view.joinX);
1428
+ joinX = Math.max(joinX, component.view.joinX);
1422
1429
  }
1423
- let joinX;
1424
1430
  let totalWidth;
1425
- if (components.length > 0) {
1426
- const restWidth = Math.max(...components.map(c => c.view.width - c.view.joinX));
1427
- joinX = Math.max(...components.map(c => c.view.joinX));
1431
+ if (sequence.length > 0) {
1428
1432
  totalWidth = joinX + restWidth;
1429
1433
  }
1430
1434
  else {
@@ -1656,7 +1660,7 @@
1656
1660
  return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
1657
1661
  const step = stepContext.step;
1658
1662
  const name = viewContext.getStepName();
1659
- const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary');
1663
+ const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary', viewContext.textWidthMeasurer);
1660
1664
  const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
1661
1665
  const halfOfWidestElement = labelView.width / 2;
1662
1666
  const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
@@ -1902,7 +1906,7 @@
1902
1906
  const step = stepContext.step;
1903
1907
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
1904
1908
  const name = viewContext.getStepName();
1905
- const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
1909
+ const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary', viewContext.textWidthMeasurer);
1906
1910
  const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
1907
1911
  if (branchNames.length === 0) {
1908
1912
  const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
@@ -1923,7 +1927,7 @@
1923
1927
  const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
1924
1928
  const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
1925
1929
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1926
- const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
1930
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary', viewContext.textWidthMeasurer);
1927
1931
  const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1928
1932
  const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1929
1933
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
@@ -1999,8 +2003,9 @@
1999
2003
  });
2000
2004
  text.textContent = viewContext.getStepName();
2001
2005
  g.appendChild(text);
2002
- const textWidth = Math.max(text.getBBox().width, cfg.minTextWidth);
2003
- const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + textWidth;
2006
+ const textWidth = viewContext.textWidthMeasurer(text);
2007
+ const width = Math.max(textWidth, cfg.minTextWidth);
2008
+ const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + width;
2004
2009
  const rect = Dom.svg('rect', {
2005
2010
  x: 0.5,
2006
2011
  y: 0.5,
@@ -2010,7 +2015,6 @@
2010
2015
  rx: cfg.radius,
2011
2016
  ry: cfg.radius
2012
2017
  });
2013
- g.insertBefore(rect, text);
2014
2018
  const iconUrl = viewContext.getStepIconUrl();
2015
2019
  const icon = iconUrl
2016
2020
  ? Dom.svg('image', {
@@ -2027,6 +2031,7 @@
2027
2031
  width: cfg.iconSize,
2028
2032
  height: cfg.iconSize
2029
2033
  });
2034
+ g.insertBefore(rect, text);
2030
2035
  g.appendChild(icon);
2031
2036
  const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
2032
2037
  const isOutputViewHidden = isInterrupted;
@@ -2713,6 +2718,7 @@
2713
2718
  const preferenceKeyPrefix = stepContext.step.id + ':';
2714
2719
  return {
2715
2720
  i18n: componentContext.i18n,
2721
+ textWidthMeasurer: componentContext.textWidthMeasurer,
2716
2722
  getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
2717
2723
  getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
2718
2724
  createStepComponent: (parentElement, parentSequence, step, position) => {
@@ -2767,13 +2773,13 @@
2767
2773
  }
2768
2774
 
2769
2775
  class ComponentContext {
2770
- static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
2776
+ static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services) {
2771
2777
  const validator = new DefinitionValidator(configuration.validator, state);
2772
2778
  const iconProvider = new IconProvider(configuration.steps);
2773
2779
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
2774
- return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state);
2780
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state);
2775
2781
  }
2776
- constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state) {
2782
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state) {
2777
2783
  this.shadowRoot = shadowRoot;
2778
2784
  this.validator = validator;
2779
2785
  this.iconProvider = iconProvider;
@@ -2783,6 +2789,7 @@
2783
2789
  this.services = services;
2784
2790
  this.preferenceStorage = preferenceStorage;
2785
2791
  this.i18n = i18n;
2792
+ this.textWidthMeasurer = textWidthMeasurer;
2786
2793
  this.state = state;
2787
2794
  }
2788
2795
  getViewportScale() {
@@ -3283,16 +3290,16 @@
3283
3290
  setSelectedStepId(stepId) {
3284
3291
  if (this.selectedStepId !== stepId) {
3285
3292
  this.selectedStepId = stepId;
3286
- this.onSelectedStepIdChanged.forward(stepId);
3293
+ this.onSelectedStepIdChanged.emit(stepId);
3287
3294
  }
3288
3295
  }
3289
3296
  pushStepIdToFolderPath(stepId) {
3290
3297
  this.folderPath.push(stepId);
3291
- this.onFolderPathChanged.forward(this.folderPath);
3298
+ this.onFolderPathChanged.emit(this.folderPath);
3292
3299
  }
3293
3300
  setFolderPath(path) {
3294
3301
  this.folderPath = path;
3295
- this.onFolderPathChanged.forward(path);
3302
+ this.onFolderPathChanged.emit(path);
3296
3303
  }
3297
3304
  tryGetLastStepIdFromFolderPath() {
3298
3305
  return this.folderPath.length > 0 ? this.folderPath[this.folderPath.length - 1] : null;
@@ -3310,50 +3317,50 @@
3310
3317
  if (details) {
3311
3318
  Object.assign(event, details);
3312
3319
  }
3313
- this.onDefinitionChanged.forward(event);
3320
+ this.onDefinitionChanged.emit(event);
3314
3321
  }
3315
3322
  notifyStepUnselectionBlocked(stepId) {
3316
- this.onStepUnselectionBlocked.forward(stepId);
3323
+ this.onStepUnselectionBlocked.emit(stepId);
3317
3324
  }
3318
3325
  setViewport(viewport) {
3319
3326
  this.viewport = viewport;
3320
- this.onViewportChanged.forward(viewport);
3327
+ this.onViewportChanged.emit(viewport);
3321
3328
  }
3322
3329
  setIsReadonly(isReadonly) {
3323
3330
  if (this.isReadonly !== isReadonly) {
3324
3331
  this.isReadonly = isReadonly;
3325
- this.onIsReadonlyChanged.forward(isReadonly);
3332
+ this.onIsReadonlyChanged.emit(isReadonly);
3326
3333
  }
3327
3334
  }
3328
3335
  setIsDragging(isDragging) {
3329
3336
  if (this.isDragging !== isDragging) {
3330
3337
  this.isDragging = isDragging;
3331
- this.onIsDraggingChanged.forward(isDragging);
3338
+ this.onIsDraggingChanged.emit(isDragging);
3332
3339
  }
3333
3340
  }
3334
3341
  setIsDragDisabled(isDragDisabled) {
3335
3342
  if (this.isDragDisabled !== isDragDisabled) {
3336
3343
  this.isDragDisabled = isDragDisabled;
3337
- this.onIsDragDisabledChanged.forward(isDragDisabled);
3344
+ this.onIsDragDisabledChanged.emit(isDragDisabled);
3338
3345
  }
3339
3346
  }
3340
3347
  setIsToolboxCollapsed(isCollapsed) {
3341
3348
  if (this.isToolboxCollapsed !== isCollapsed) {
3342
3349
  this.isToolboxCollapsed = isCollapsed;
3343
- this.onIsToolboxCollapsedChanged.forward(isCollapsed);
3350
+ this.onIsToolboxCollapsedChanged.emit(isCollapsed);
3344
3351
  }
3345
3352
  }
3346
3353
  setIsEditorCollapsed(isCollapsed) {
3347
3354
  if (this.isEditorCollapsed !== isCollapsed) {
3348
3355
  this.isEditorCollapsed = isCollapsed;
3349
- this.onIsEditorCollapsedChanged.forward(isCollapsed);
3356
+ this.onIsEditorCollapsedChanged.emit(isCollapsed);
3350
3357
  }
3351
3358
  }
3352
3359
  setPreferences(changes, stepId) {
3353
3360
  for (const change of changes) {
3354
3361
  this.preferenceStorage.setItem(change.key, change.value);
3355
3362
  }
3356
- this.onPreferencesChanged.forward({ changes, stepId });
3363
+ this.onPreferencesChanged.emit({ changes, stepId });
3357
3364
  }
3358
3365
  getPreference(key) {
3359
3366
  return this.preferenceStorage.getItem(key);
@@ -3503,9 +3510,13 @@
3503
3510
  }
3504
3511
  }
3505
3512
 
3513
+ function measureTextWidth(text) {
3514
+ return text.getBBox().width;
3515
+ }
3516
+
3506
3517
  class DesignerContext {
3507
3518
  static create(placeholder, startDefinition, configuration, services) {
3508
- var _a, _b, _c, _d, _e, _f;
3519
+ var _a, _b, _c, _d, _e, _f, _g;
3509
3520
  const definition = ObjectCloner.deepClone(startDefinition);
3510
3521
  const layoutController = new LayoutController(placeholder);
3511
3522
  const isReadonly = Boolean(configuration.isReadonly);
@@ -3521,13 +3532,14 @@
3521
3532
  const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new DefinitionWalker();
3522
3533
  const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
3523
3534
  const uidGenerator = (_f = configuration.uidGenerator) !== null && _f !== void 0 ? _f : Uid.next;
3535
+ const textWidthMeasurer = (_g = configuration.textWidthMeasurer) !== null && _g !== void 0 ? _g : measureTextWidth;
3524
3536
  const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
3525
3537
  const customActionController = new CustomActionController(configuration, state, stateModifier);
3526
3538
  let historyController = undefined;
3527
3539
  if (configuration.undoStackSize) {
3528
3540
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
3529
3541
  }
3530
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services);
3542
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services);
3531
3543
  return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3532
3544
  }
3533
3545
  constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
@@ -4194,7 +4206,7 @@
4194
4206
  this.view.render(rootSequence.sequence, parentPlaceIndicator);
4195
4207
  this.trySelectStepComponent(this.state.selectedStepId);
4196
4208
  this.updateBadges();
4197
- this.onRootComponentUpdated.forward();
4209
+ this.onRootComponentUpdated.emit();
4198
4210
  };
4199
4211
  this.onClick = (position, target, buttonIndex, altKey) => {
4200
4212
  const isPrimaryButton = buttonIndex === 0;
@@ -5262,21 +5274,22 @@
5262
5274
  const designerApi = DesignerApi.create(designerContext);
5263
5275
  const view = DesignerView.create(placeholder, designerContext, designerApi);
5264
5276
  const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
5265
- view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.forward);
5266
- view.workspace.onRootComponentUpdated.once().then(designer.onReady.forward);
5277
+ view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.emit);
5278
+ view.workspace.onRootComponentUpdated.once().then(designer.onReady.emit);
5267
5279
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
5268
5280
  if (definition !== undefined) {
5269
- designer.onDefinitionChanged.forward(definition);
5281
+ designer.onDefinitionChanged.emit(definition);
5270
5282
  }
5271
5283
  if (selectedStepId !== undefined) {
5272
- designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
5284
+ designer.onSelectedStepIdChanged.emit(designerContext.state.selectedStepId);
5273
5285
  }
5274
5286
  });
5275
- designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.forward);
5276
- designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.forward);
5277
- designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.forward);
5278
- designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.forward);
5279
- designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.forward);
5287
+ designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.emit);
5288
+ designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.emit);
5289
+ designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.emit);
5290
+ designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.emit);
5291
+ designerContext.state.onIsDraggingChanged.subscribe(designer.onIsDraggingChanged.emit);
5292
+ designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.emit);
5280
5293
  return designer;
5281
5294
  }
5282
5295
  constructor(view, state, walker, historyController, api) {
@@ -5317,6 +5330,10 @@
5317
5330
  * @description Fires when the root component and all its children are rerendered.
5318
5331
  */
5319
5332
  this.onRootComponentUpdated = new SimpleEvent();
5333
+ /**
5334
+ * @description Fires when the dragging state has changed. `true` if the step is being dragged, otherwise `false`.
5335
+ */
5336
+ this.onIsDraggingChanged = new SimpleEvent();
5320
5337
  /**
5321
5338
  * @description Fires when any of the designer preferences has changed.
5322
5339
  */
@@ -5426,6 +5443,12 @@
5426
5443
  isEditorCollapsed() {
5427
5444
  return this.state.isEditorCollapsed;
5428
5445
  }
5446
+ /**
5447
+ * @returns a flag that indicates whether the step is being dragged.
5448
+ */
5449
+ isDragging() {
5450
+ return this.state.isDragging;
5451
+ }
5429
5452
  /**
5430
5453
  * @description Sets a flag that indicates whether the editor is collapsed.
5431
5454
  */
package/lib/cjs/index.cjs CHANGED
@@ -14,10 +14,11 @@ class Dom {
14
14
  element.setAttribute('transform', `translate(${x}, ${y})`);
15
15
  }
16
16
  static attrs(element, attributes) {
17
- Object.keys(attributes).forEach(name => {
17
+ const names = Object.keys(attributes);
18
+ for (const name in names) {
18
19
  const value = attributes[name];
19
20
  element.setAttribute(name, typeof value === 'string' ? value : value.toString());
20
- });
21
+ }
21
22
  }
22
23
  static element(name, attributes) {
23
24
  const element = document.createElement(name);
@@ -131,9 +132,9 @@ class Uid {
131
132
  class SimpleEvent {
132
133
  constructor() {
133
134
  this.listeners = [];
134
- this.forward = (value) => {
135
- if (this.listeners.length > 0) {
136
- this.listeners.forEach(listener => listener(value));
135
+ this.emit = (value) => {
136
+ for (const listener of this.listeners) {
137
+ listener(value);
137
138
  }
138
139
  };
139
140
  }
@@ -167,14 +168,14 @@ function race(timeout, a, b, c, d) {
167
168
  const value = [undefined, undefined, undefined, undefined];
168
169
  const result = new SimpleEvent();
169
170
  let scheduled = false;
170
- function forward() {
171
+ function emit() {
171
172
  if (scheduled) {
172
173
  return;
173
174
  }
174
175
  scheduled = true;
175
176
  setTimeout(() => {
176
177
  try {
177
- result.forward(value);
178
+ result.emit(value);
178
179
  }
179
180
  finally {
180
181
  scheduled = false;
@@ -185,7 +186,7 @@ function race(timeout, a, b, c, d) {
185
186
  function subscribe(event, index) {
186
187
  event.subscribe(v => {
187
188
  value[index] = v;
188
- forward();
189
+ emit();
189
190
  });
190
191
  }
191
192
  subscribe(a, 0);
@@ -202,7 +203,7 @@ function race(timeout, a, b, c, d) {
202
203
  class ControlBarApi {
203
204
  static create(state, historyController, stateModifier) {
204
205
  const api = new ControlBarApi(state, historyController, stateModifier);
205
- race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.forward);
206
+ race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.emit);
206
207
  return api;
207
208
  }
208
209
  constructor(state, historyController, stateModifier) {
@@ -1155,7 +1156,7 @@ function appendJoin(parent, d) {
1155
1156
  }
1156
1157
 
1157
1158
  class LabelView {
1158
- static create(parent, y, cfg, text, theme) {
1159
+ static create(parent, y, cfg, text, theme, textWidthMeasurer) {
1159
1160
  const g = Dom.svg('g', {
1160
1161
  class: `sqd-label sqd-label-${theme}`
1161
1162
  });
@@ -1166,7 +1167,8 @@ class LabelView {
1166
1167
  });
1167
1168
  nameText.textContent = text;
1168
1169
  g.appendChild(nameText);
1169
- const width = Math.max(nameText.getBBox().width + cfg.paddingX * 2, cfg.minWidth);
1170
+ const nameWidth = textWidthMeasurer(nameText);
1171
+ const width = Math.max(nameWidth + cfg.paddingX * 2, cfg.minWidth);
1170
1172
  const nameRect = Dom.svg('rect', {
1171
1173
  class: 'sqd-label-rect',
1172
1174
  width: width,
@@ -1222,7 +1224,9 @@ class DefaultSequenceComponentView {
1222
1224
  const { sequence } = sequenceContext;
1223
1225
  const g = Dom.svg('g');
1224
1226
  parent.appendChild(g);
1225
- const components = [];
1227
+ const components = new Array(sequence.length);
1228
+ let restWidth = 0;
1229
+ let joinX = 0;
1226
1230
  for (let index = 0; index < sequence.length; index++) {
1227
1231
  const stepContext = {
1228
1232
  parentSequence: sequenceContext.sequence,
@@ -1233,13 +1237,13 @@ class DefaultSequenceComponentView {
1233
1237
  isOutputConnected: index === sequence.length - 1 ? sequenceContext.isOutputConnected : true,
1234
1238
  isPreview: sequenceContext.isPreview
1235
1239
  };
1236
- components[index] = componentContext.stepComponentFactory.create(g, stepContext, componentContext);
1240
+ const component = componentContext.stepComponentFactory.create(g, stepContext, componentContext);
1241
+ components[index] = component;
1242
+ restWidth = Math.max(restWidth, component.view.width - component.view.joinX);
1243
+ joinX = Math.max(joinX, component.view.joinX);
1237
1244
  }
1238
- let joinX;
1239
1245
  let totalWidth;
1240
- if (components.length > 0) {
1241
- const restWidth = Math.max(...components.map(c => c.view.width - c.view.joinX));
1242
- joinX = Math.max(...components.map(c => c.view.joinX));
1246
+ if (sequence.length > 0) {
1243
1247
  totalWidth = joinX + restWidth;
1244
1248
  }
1245
1249
  else {
@@ -1471,7 +1475,7 @@ const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepCon
1471
1475
  return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
1472
1476
  const step = stepContext.step;
1473
1477
  const name = viewContext.getStepName();
1474
- const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary');
1478
+ const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary', viewContext.textWidthMeasurer);
1475
1479
  const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
1476
1480
  const halfOfWidestElement = labelView.width / 2;
1477
1481
  const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
@@ -1717,7 +1721,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
1717
1721
  const step = stepContext.step;
1718
1722
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
1719
1723
  const name = viewContext.getStepName();
1720
- const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
1724
+ const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary', viewContext.textWidthMeasurer);
1721
1725
  const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
1722
1726
  if (branchNames.length === 0) {
1723
1727
  const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
@@ -1738,7 +1742,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
1738
1742
  const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
1739
1743
  const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
1740
1744
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1741
- const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
1745
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary', viewContext.textWidthMeasurer);
1742
1746
  const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1743
1747
  const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1744
1748
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
@@ -1814,8 +1818,9 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1814
1818
  });
1815
1819
  text.textContent = viewContext.getStepName();
1816
1820
  g.appendChild(text);
1817
- const textWidth = Math.max(text.getBBox().width, cfg.minTextWidth);
1818
- const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + textWidth;
1821
+ const textWidth = viewContext.textWidthMeasurer(text);
1822
+ const width = Math.max(textWidth, cfg.minTextWidth);
1823
+ const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + width;
1819
1824
  const rect = Dom.svg('rect', {
1820
1825
  x: 0.5,
1821
1826
  y: 0.5,
@@ -1825,7 +1830,6 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1825
1830
  rx: cfg.radius,
1826
1831
  ry: cfg.radius
1827
1832
  });
1828
- g.insertBefore(rect, text);
1829
1833
  const iconUrl = viewContext.getStepIconUrl();
1830
1834
  const icon = iconUrl
1831
1835
  ? Dom.svg('image', {
@@ -1842,6 +1846,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1842
1846
  width: cfg.iconSize,
1843
1847
  height: cfg.iconSize
1844
1848
  });
1849
+ g.insertBefore(rect, text);
1845
1850
  g.appendChild(icon);
1846
1851
  const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
1847
1852
  const isOutputViewHidden = isInterrupted;
@@ -2528,6 +2533,7 @@ class StepComponentViewContextFactory {
2528
2533
  const preferenceKeyPrefix = stepContext.step.id + ':';
2529
2534
  return {
2530
2535
  i18n: componentContext.i18n,
2536
+ textWidthMeasurer: componentContext.textWidthMeasurer,
2531
2537
  getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
2532
2538
  getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
2533
2539
  createStepComponent: (parentElement, parentSequence, step, position) => {
@@ -2582,13 +2588,13 @@ class StepComponentFactory {
2582
2588
  }
2583
2589
 
2584
2590
  class ComponentContext {
2585
- static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
2591
+ static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services) {
2586
2592
  const validator = new DefinitionValidator(configuration.validator, state);
2587
2593
  const iconProvider = new IconProvider(configuration.steps);
2588
2594
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
2589
- return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state);
2595
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state);
2590
2596
  }
2591
- constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state) {
2597
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state) {
2592
2598
  this.shadowRoot = shadowRoot;
2593
2599
  this.validator = validator;
2594
2600
  this.iconProvider = iconProvider;
@@ -2598,6 +2604,7 @@ class ComponentContext {
2598
2604
  this.services = services;
2599
2605
  this.preferenceStorage = preferenceStorage;
2600
2606
  this.i18n = i18n;
2607
+ this.textWidthMeasurer = textWidthMeasurer;
2601
2608
  this.state = state;
2602
2609
  }
2603
2610
  getViewportScale() {
@@ -3098,16 +3105,16 @@ class DesignerState {
3098
3105
  setSelectedStepId(stepId) {
3099
3106
  if (this.selectedStepId !== stepId) {
3100
3107
  this.selectedStepId = stepId;
3101
- this.onSelectedStepIdChanged.forward(stepId);
3108
+ this.onSelectedStepIdChanged.emit(stepId);
3102
3109
  }
3103
3110
  }
3104
3111
  pushStepIdToFolderPath(stepId) {
3105
3112
  this.folderPath.push(stepId);
3106
- this.onFolderPathChanged.forward(this.folderPath);
3113
+ this.onFolderPathChanged.emit(this.folderPath);
3107
3114
  }
3108
3115
  setFolderPath(path) {
3109
3116
  this.folderPath = path;
3110
- this.onFolderPathChanged.forward(path);
3117
+ this.onFolderPathChanged.emit(path);
3111
3118
  }
3112
3119
  tryGetLastStepIdFromFolderPath() {
3113
3120
  return this.folderPath.length > 0 ? this.folderPath[this.folderPath.length - 1] : null;
@@ -3125,50 +3132,50 @@ class DesignerState {
3125
3132
  if (details) {
3126
3133
  Object.assign(event, details);
3127
3134
  }
3128
- this.onDefinitionChanged.forward(event);
3135
+ this.onDefinitionChanged.emit(event);
3129
3136
  }
3130
3137
  notifyStepUnselectionBlocked(stepId) {
3131
- this.onStepUnselectionBlocked.forward(stepId);
3138
+ this.onStepUnselectionBlocked.emit(stepId);
3132
3139
  }
3133
3140
  setViewport(viewport) {
3134
3141
  this.viewport = viewport;
3135
- this.onViewportChanged.forward(viewport);
3142
+ this.onViewportChanged.emit(viewport);
3136
3143
  }
3137
3144
  setIsReadonly(isReadonly) {
3138
3145
  if (this.isReadonly !== isReadonly) {
3139
3146
  this.isReadonly = isReadonly;
3140
- this.onIsReadonlyChanged.forward(isReadonly);
3147
+ this.onIsReadonlyChanged.emit(isReadonly);
3141
3148
  }
3142
3149
  }
3143
3150
  setIsDragging(isDragging) {
3144
3151
  if (this.isDragging !== isDragging) {
3145
3152
  this.isDragging = isDragging;
3146
- this.onIsDraggingChanged.forward(isDragging);
3153
+ this.onIsDraggingChanged.emit(isDragging);
3147
3154
  }
3148
3155
  }
3149
3156
  setIsDragDisabled(isDragDisabled) {
3150
3157
  if (this.isDragDisabled !== isDragDisabled) {
3151
3158
  this.isDragDisabled = isDragDisabled;
3152
- this.onIsDragDisabledChanged.forward(isDragDisabled);
3159
+ this.onIsDragDisabledChanged.emit(isDragDisabled);
3153
3160
  }
3154
3161
  }
3155
3162
  setIsToolboxCollapsed(isCollapsed) {
3156
3163
  if (this.isToolboxCollapsed !== isCollapsed) {
3157
3164
  this.isToolboxCollapsed = isCollapsed;
3158
- this.onIsToolboxCollapsedChanged.forward(isCollapsed);
3165
+ this.onIsToolboxCollapsedChanged.emit(isCollapsed);
3159
3166
  }
3160
3167
  }
3161
3168
  setIsEditorCollapsed(isCollapsed) {
3162
3169
  if (this.isEditorCollapsed !== isCollapsed) {
3163
3170
  this.isEditorCollapsed = isCollapsed;
3164
- this.onIsEditorCollapsedChanged.forward(isCollapsed);
3171
+ this.onIsEditorCollapsedChanged.emit(isCollapsed);
3165
3172
  }
3166
3173
  }
3167
3174
  setPreferences(changes, stepId) {
3168
3175
  for (const change of changes) {
3169
3176
  this.preferenceStorage.setItem(change.key, change.value);
3170
3177
  }
3171
- this.onPreferencesChanged.forward({ changes, stepId });
3178
+ this.onPreferencesChanged.emit({ changes, stepId });
3172
3179
  }
3173
3180
  getPreference(key) {
3174
3181
  return this.preferenceStorage.getItem(key);
@@ -3318,9 +3325,13 @@ class MemoryPreferenceStorage {
3318
3325
  }
3319
3326
  }
3320
3327
 
3328
+ function measureTextWidth(text) {
3329
+ return text.getBBox().width;
3330
+ }
3331
+
3321
3332
  class DesignerContext {
3322
3333
  static create(placeholder, startDefinition, configuration, services) {
3323
- var _a, _b, _c, _d, _e, _f;
3334
+ var _a, _b, _c, _d, _e, _f, _g;
3324
3335
  const definition = ObjectCloner.deepClone(startDefinition);
3325
3336
  const layoutController = new LayoutController(placeholder);
3326
3337
  const isReadonly = Boolean(configuration.isReadonly);
@@ -3336,13 +3347,14 @@ class DesignerContext {
3336
3347
  const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new sequentialWorkflowModel.DefinitionWalker();
3337
3348
  const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
3338
3349
  const uidGenerator = (_f = configuration.uidGenerator) !== null && _f !== void 0 ? _f : Uid.next;
3350
+ const textWidthMeasurer = (_g = configuration.textWidthMeasurer) !== null && _g !== void 0 ? _g : measureTextWidth;
3339
3351
  const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
3340
3352
  const customActionController = new CustomActionController(configuration, state, stateModifier);
3341
3353
  let historyController = undefined;
3342
3354
  if (configuration.undoStackSize) {
3343
3355
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
3344
3356
  }
3345
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services);
3357
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services);
3346
3358
  return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3347
3359
  }
3348
3360
  constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
@@ -4009,7 +4021,7 @@ class Workspace {
4009
4021
  this.view.render(rootSequence.sequence, parentPlaceIndicator);
4010
4022
  this.trySelectStepComponent(this.state.selectedStepId);
4011
4023
  this.updateBadges();
4012
- this.onRootComponentUpdated.forward();
4024
+ this.onRootComponentUpdated.emit();
4013
4025
  };
4014
4026
  this.onClick = (position, target, buttonIndex, altKey) => {
4015
4027
  const isPrimaryButton = buttonIndex === 0;
@@ -5077,21 +5089,22 @@ class Designer {
5077
5089
  const designerApi = DesignerApi.create(designerContext);
5078
5090
  const view = DesignerView.create(placeholder, designerContext, designerApi);
5079
5091
  const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
5080
- view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.forward);
5081
- view.workspace.onRootComponentUpdated.once().then(designer.onReady.forward);
5092
+ view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.emit);
5093
+ view.workspace.onRootComponentUpdated.once().then(designer.onReady.emit);
5082
5094
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
5083
5095
  if (definition !== undefined) {
5084
- designer.onDefinitionChanged.forward(definition);
5096
+ designer.onDefinitionChanged.emit(definition);
5085
5097
  }
5086
5098
  if (selectedStepId !== undefined) {
5087
- designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
5099
+ designer.onSelectedStepIdChanged.emit(designerContext.state.selectedStepId);
5088
5100
  }
5089
5101
  });
5090
- designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.forward);
5091
- designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.forward);
5092
- designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.forward);
5093
- designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.forward);
5094
- designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.forward);
5102
+ designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.emit);
5103
+ designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.emit);
5104
+ designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.emit);
5105
+ designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.emit);
5106
+ designerContext.state.onIsDraggingChanged.subscribe(designer.onIsDraggingChanged.emit);
5107
+ designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.emit);
5095
5108
  return designer;
5096
5109
  }
5097
5110
  constructor(view, state, walker, historyController, api) {
@@ -5132,6 +5145,10 @@ class Designer {
5132
5145
  * @description Fires when the root component and all its children are rerendered.
5133
5146
  */
5134
5147
  this.onRootComponentUpdated = new SimpleEvent();
5148
+ /**
5149
+ * @description Fires when the dragging state has changed. `true` if the step is being dragged, otherwise `false`.
5150
+ */
5151
+ this.onIsDraggingChanged = new SimpleEvent();
5135
5152
  /**
5136
5153
  * @description Fires when any of the designer preferences has changed.
5137
5154
  */
@@ -5241,6 +5258,12 @@ class Designer {
5241
5258
  isEditorCollapsed() {
5242
5259
  return this.state.isEditorCollapsed;
5243
5260
  }
5261
+ /**
5262
+ * @returns a flag that indicates whether the step is being dragged.
5263
+ */
5264
+ isDragging() {
5265
+ return this.state.isDragging;
5266
+ }
5244
5267
  /**
5245
5268
  * @description Sets a flag that indicates whether the editor is collapsed.
5246
5269
  */
package/lib/esm/index.js CHANGED
@@ -13,10 +13,11 @@ class Dom {
13
13
  element.setAttribute('transform', `translate(${x}, ${y})`);
14
14
  }
15
15
  static attrs(element, attributes) {
16
- Object.keys(attributes).forEach(name => {
16
+ const names = Object.keys(attributes);
17
+ for (const name in names) {
17
18
  const value = attributes[name];
18
19
  element.setAttribute(name, typeof value === 'string' ? value : value.toString());
19
- });
20
+ }
20
21
  }
21
22
  static element(name, attributes) {
22
23
  const element = document.createElement(name);
@@ -130,9 +131,9 @@ class Uid {
130
131
  class SimpleEvent {
131
132
  constructor() {
132
133
  this.listeners = [];
133
- this.forward = (value) => {
134
- if (this.listeners.length > 0) {
135
- this.listeners.forEach(listener => listener(value));
134
+ this.emit = (value) => {
135
+ for (const listener of this.listeners) {
136
+ listener(value);
136
137
  }
137
138
  };
138
139
  }
@@ -166,14 +167,14 @@ function race(timeout, a, b, c, d) {
166
167
  const value = [undefined, undefined, undefined, undefined];
167
168
  const result = new SimpleEvent();
168
169
  let scheduled = false;
169
- function forward() {
170
+ function emit() {
170
171
  if (scheduled) {
171
172
  return;
172
173
  }
173
174
  scheduled = true;
174
175
  setTimeout(() => {
175
176
  try {
176
- result.forward(value);
177
+ result.emit(value);
177
178
  }
178
179
  finally {
179
180
  scheduled = false;
@@ -184,7 +185,7 @@ function race(timeout, a, b, c, d) {
184
185
  function subscribe(event, index) {
185
186
  event.subscribe(v => {
186
187
  value[index] = v;
187
- forward();
188
+ emit();
188
189
  });
189
190
  }
190
191
  subscribe(a, 0);
@@ -201,7 +202,7 @@ function race(timeout, a, b, c, d) {
201
202
  class ControlBarApi {
202
203
  static create(state, historyController, stateModifier) {
203
204
  const api = new ControlBarApi(state, historyController, stateModifier);
204
- race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.forward);
205
+ race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.emit);
205
206
  return api;
206
207
  }
207
208
  constructor(state, historyController, stateModifier) {
@@ -1154,7 +1155,7 @@ function appendJoin(parent, d) {
1154
1155
  }
1155
1156
 
1156
1157
  class LabelView {
1157
- static create(parent, y, cfg, text, theme) {
1158
+ static create(parent, y, cfg, text, theme, textWidthMeasurer) {
1158
1159
  const g = Dom.svg('g', {
1159
1160
  class: `sqd-label sqd-label-${theme}`
1160
1161
  });
@@ -1165,7 +1166,8 @@ class LabelView {
1165
1166
  });
1166
1167
  nameText.textContent = text;
1167
1168
  g.appendChild(nameText);
1168
- const width = Math.max(nameText.getBBox().width + cfg.paddingX * 2, cfg.minWidth);
1169
+ const nameWidth = textWidthMeasurer(nameText);
1170
+ const width = Math.max(nameWidth + cfg.paddingX * 2, cfg.minWidth);
1169
1171
  const nameRect = Dom.svg('rect', {
1170
1172
  class: 'sqd-label-rect',
1171
1173
  width: width,
@@ -1221,7 +1223,9 @@ class DefaultSequenceComponentView {
1221
1223
  const { sequence } = sequenceContext;
1222
1224
  const g = Dom.svg('g');
1223
1225
  parent.appendChild(g);
1224
- const components = [];
1226
+ const components = new Array(sequence.length);
1227
+ let restWidth = 0;
1228
+ let joinX = 0;
1225
1229
  for (let index = 0; index < sequence.length; index++) {
1226
1230
  const stepContext = {
1227
1231
  parentSequence: sequenceContext.sequence,
@@ -1232,13 +1236,13 @@ class DefaultSequenceComponentView {
1232
1236
  isOutputConnected: index === sequence.length - 1 ? sequenceContext.isOutputConnected : true,
1233
1237
  isPreview: sequenceContext.isPreview
1234
1238
  };
1235
- components[index] = componentContext.stepComponentFactory.create(g, stepContext, componentContext);
1239
+ const component = componentContext.stepComponentFactory.create(g, stepContext, componentContext);
1240
+ components[index] = component;
1241
+ restWidth = Math.max(restWidth, component.view.width - component.view.joinX);
1242
+ joinX = Math.max(joinX, component.view.joinX);
1236
1243
  }
1237
- let joinX;
1238
1244
  let totalWidth;
1239
- if (components.length > 0) {
1240
- const restWidth = Math.max(...components.map(c => c.view.width - c.view.joinX));
1241
- joinX = Math.max(...components.map(c => c.view.joinX));
1245
+ if (sequence.length > 0) {
1242
1246
  totalWidth = joinX + restWidth;
1243
1247
  }
1244
1248
  else {
@@ -1470,7 +1474,7 @@ const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepCon
1470
1474
  return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
1471
1475
  const step = stepContext.step;
1472
1476
  const name = viewContext.getStepName();
1473
- const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary');
1477
+ const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary', viewContext.textWidthMeasurer);
1474
1478
  const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
1475
1479
  const halfOfWidestElement = labelView.width / 2;
1476
1480
  const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
@@ -1716,7 +1720,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
1716
1720
  const step = stepContext.step;
1717
1721
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
1718
1722
  const name = viewContext.getStepName();
1719
- const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
1723
+ const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary', viewContext.textWidthMeasurer);
1720
1724
  const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
1721
1725
  if (branchNames.length === 0) {
1722
1726
  const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
@@ -1737,7 +1741,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
1737
1741
  const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
1738
1742
  const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
1739
1743
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1740
- const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
1744
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary', viewContext.textWidthMeasurer);
1741
1745
  const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1742
1746
  const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1743
1747
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
@@ -1813,8 +1817,9 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1813
1817
  });
1814
1818
  text.textContent = viewContext.getStepName();
1815
1819
  g.appendChild(text);
1816
- const textWidth = Math.max(text.getBBox().width, cfg.minTextWidth);
1817
- const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + textWidth;
1820
+ const textWidth = viewContext.textWidthMeasurer(text);
1821
+ const width = Math.max(textWidth, cfg.minTextWidth);
1822
+ const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + width;
1818
1823
  const rect = Dom.svg('rect', {
1819
1824
  x: 0.5,
1820
1825
  y: 0.5,
@@ -1824,7 +1829,6 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1824
1829
  rx: cfg.radius,
1825
1830
  ry: cfg.radius
1826
1831
  });
1827
- g.insertBefore(rect, text);
1828
1832
  const iconUrl = viewContext.getStepIconUrl();
1829
1833
  const icon = iconUrl
1830
1834
  ? Dom.svg('image', {
@@ -1841,6 +1845,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1841
1845
  width: cfg.iconSize,
1842
1846
  height: cfg.iconSize
1843
1847
  });
1848
+ g.insertBefore(rect, text);
1844
1849
  g.appendChild(icon);
1845
1850
  const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
1846
1851
  const isOutputViewHidden = isInterrupted;
@@ -2527,6 +2532,7 @@ class StepComponentViewContextFactory {
2527
2532
  const preferenceKeyPrefix = stepContext.step.id + ':';
2528
2533
  return {
2529
2534
  i18n: componentContext.i18n,
2535
+ textWidthMeasurer: componentContext.textWidthMeasurer,
2530
2536
  getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
2531
2537
  getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
2532
2538
  createStepComponent: (parentElement, parentSequence, step, position) => {
@@ -2581,13 +2587,13 @@ class StepComponentFactory {
2581
2587
  }
2582
2588
 
2583
2589
  class ComponentContext {
2584
- static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
2590
+ static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services) {
2585
2591
  const validator = new DefinitionValidator(configuration.validator, state);
2586
2592
  const iconProvider = new IconProvider(configuration.steps);
2587
2593
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
2588
- return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state);
2594
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state);
2589
2595
  }
2590
- constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state) {
2596
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state) {
2591
2597
  this.shadowRoot = shadowRoot;
2592
2598
  this.validator = validator;
2593
2599
  this.iconProvider = iconProvider;
@@ -2597,6 +2603,7 @@ class ComponentContext {
2597
2603
  this.services = services;
2598
2604
  this.preferenceStorage = preferenceStorage;
2599
2605
  this.i18n = i18n;
2606
+ this.textWidthMeasurer = textWidthMeasurer;
2600
2607
  this.state = state;
2601
2608
  }
2602
2609
  getViewportScale() {
@@ -3097,16 +3104,16 @@ class DesignerState {
3097
3104
  setSelectedStepId(stepId) {
3098
3105
  if (this.selectedStepId !== stepId) {
3099
3106
  this.selectedStepId = stepId;
3100
- this.onSelectedStepIdChanged.forward(stepId);
3107
+ this.onSelectedStepIdChanged.emit(stepId);
3101
3108
  }
3102
3109
  }
3103
3110
  pushStepIdToFolderPath(stepId) {
3104
3111
  this.folderPath.push(stepId);
3105
- this.onFolderPathChanged.forward(this.folderPath);
3112
+ this.onFolderPathChanged.emit(this.folderPath);
3106
3113
  }
3107
3114
  setFolderPath(path) {
3108
3115
  this.folderPath = path;
3109
- this.onFolderPathChanged.forward(path);
3116
+ this.onFolderPathChanged.emit(path);
3110
3117
  }
3111
3118
  tryGetLastStepIdFromFolderPath() {
3112
3119
  return this.folderPath.length > 0 ? this.folderPath[this.folderPath.length - 1] : null;
@@ -3124,50 +3131,50 @@ class DesignerState {
3124
3131
  if (details) {
3125
3132
  Object.assign(event, details);
3126
3133
  }
3127
- this.onDefinitionChanged.forward(event);
3134
+ this.onDefinitionChanged.emit(event);
3128
3135
  }
3129
3136
  notifyStepUnselectionBlocked(stepId) {
3130
- this.onStepUnselectionBlocked.forward(stepId);
3137
+ this.onStepUnselectionBlocked.emit(stepId);
3131
3138
  }
3132
3139
  setViewport(viewport) {
3133
3140
  this.viewport = viewport;
3134
- this.onViewportChanged.forward(viewport);
3141
+ this.onViewportChanged.emit(viewport);
3135
3142
  }
3136
3143
  setIsReadonly(isReadonly) {
3137
3144
  if (this.isReadonly !== isReadonly) {
3138
3145
  this.isReadonly = isReadonly;
3139
- this.onIsReadonlyChanged.forward(isReadonly);
3146
+ this.onIsReadonlyChanged.emit(isReadonly);
3140
3147
  }
3141
3148
  }
3142
3149
  setIsDragging(isDragging) {
3143
3150
  if (this.isDragging !== isDragging) {
3144
3151
  this.isDragging = isDragging;
3145
- this.onIsDraggingChanged.forward(isDragging);
3152
+ this.onIsDraggingChanged.emit(isDragging);
3146
3153
  }
3147
3154
  }
3148
3155
  setIsDragDisabled(isDragDisabled) {
3149
3156
  if (this.isDragDisabled !== isDragDisabled) {
3150
3157
  this.isDragDisabled = isDragDisabled;
3151
- this.onIsDragDisabledChanged.forward(isDragDisabled);
3158
+ this.onIsDragDisabledChanged.emit(isDragDisabled);
3152
3159
  }
3153
3160
  }
3154
3161
  setIsToolboxCollapsed(isCollapsed) {
3155
3162
  if (this.isToolboxCollapsed !== isCollapsed) {
3156
3163
  this.isToolboxCollapsed = isCollapsed;
3157
- this.onIsToolboxCollapsedChanged.forward(isCollapsed);
3164
+ this.onIsToolboxCollapsedChanged.emit(isCollapsed);
3158
3165
  }
3159
3166
  }
3160
3167
  setIsEditorCollapsed(isCollapsed) {
3161
3168
  if (this.isEditorCollapsed !== isCollapsed) {
3162
3169
  this.isEditorCollapsed = isCollapsed;
3163
- this.onIsEditorCollapsedChanged.forward(isCollapsed);
3170
+ this.onIsEditorCollapsedChanged.emit(isCollapsed);
3164
3171
  }
3165
3172
  }
3166
3173
  setPreferences(changes, stepId) {
3167
3174
  for (const change of changes) {
3168
3175
  this.preferenceStorage.setItem(change.key, change.value);
3169
3176
  }
3170
- this.onPreferencesChanged.forward({ changes, stepId });
3177
+ this.onPreferencesChanged.emit({ changes, stepId });
3171
3178
  }
3172
3179
  getPreference(key) {
3173
3180
  return this.preferenceStorage.getItem(key);
@@ -3317,9 +3324,13 @@ class MemoryPreferenceStorage {
3317
3324
  }
3318
3325
  }
3319
3326
 
3327
+ function measureTextWidth(text) {
3328
+ return text.getBBox().width;
3329
+ }
3330
+
3320
3331
  class DesignerContext {
3321
3332
  static create(placeholder, startDefinition, configuration, services) {
3322
- var _a, _b, _c, _d, _e, _f;
3333
+ var _a, _b, _c, _d, _e, _f, _g;
3323
3334
  const definition = ObjectCloner.deepClone(startDefinition);
3324
3335
  const layoutController = new LayoutController(placeholder);
3325
3336
  const isReadonly = Boolean(configuration.isReadonly);
@@ -3335,13 +3346,14 @@ class DesignerContext {
3335
3346
  const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new DefinitionWalker();
3336
3347
  const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
3337
3348
  const uidGenerator = (_f = configuration.uidGenerator) !== null && _f !== void 0 ? _f : Uid.next;
3349
+ const textWidthMeasurer = (_g = configuration.textWidthMeasurer) !== null && _g !== void 0 ? _g : measureTextWidth;
3338
3350
  const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
3339
3351
  const customActionController = new CustomActionController(configuration, state, stateModifier);
3340
3352
  let historyController = undefined;
3341
3353
  if (configuration.undoStackSize) {
3342
3354
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
3343
3355
  }
3344
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services);
3356
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services);
3345
3357
  return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3346
3358
  }
3347
3359
  constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
@@ -4008,7 +4020,7 @@ class Workspace {
4008
4020
  this.view.render(rootSequence.sequence, parentPlaceIndicator);
4009
4021
  this.trySelectStepComponent(this.state.selectedStepId);
4010
4022
  this.updateBadges();
4011
- this.onRootComponentUpdated.forward();
4023
+ this.onRootComponentUpdated.emit();
4012
4024
  };
4013
4025
  this.onClick = (position, target, buttonIndex, altKey) => {
4014
4026
  const isPrimaryButton = buttonIndex === 0;
@@ -5076,21 +5088,22 @@ class Designer {
5076
5088
  const designerApi = DesignerApi.create(designerContext);
5077
5089
  const view = DesignerView.create(placeholder, designerContext, designerApi);
5078
5090
  const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
5079
- view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.forward);
5080
- view.workspace.onRootComponentUpdated.once().then(designer.onReady.forward);
5091
+ view.workspace.onRootComponentUpdated.subscribe(designer.onRootComponentUpdated.emit);
5092
+ view.workspace.onRootComponentUpdated.once().then(designer.onReady.emit);
5081
5093
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
5082
5094
  if (definition !== undefined) {
5083
- designer.onDefinitionChanged.forward(definition);
5095
+ designer.onDefinitionChanged.emit(definition);
5084
5096
  }
5085
5097
  if (selectedStepId !== undefined) {
5086
- designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
5098
+ designer.onSelectedStepIdChanged.emit(designerContext.state.selectedStepId);
5087
5099
  }
5088
5100
  });
5089
- designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.forward);
5090
- designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.forward);
5091
- designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.forward);
5092
- designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.forward);
5093
- designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.forward);
5101
+ designerContext.state.onViewportChanged.subscribe(designer.onViewportChanged.emit);
5102
+ designerContext.state.onIsToolboxCollapsedChanged.subscribe(designer.onIsToolboxCollapsedChanged.emit);
5103
+ designerContext.state.onIsEditorCollapsedChanged.subscribe(designer.onIsEditorCollapsedChanged.emit);
5104
+ designerContext.state.onStepUnselectionBlocked.subscribe(designer.onStepUnselectionBlocked.emit);
5105
+ designerContext.state.onIsDraggingChanged.subscribe(designer.onIsDraggingChanged.emit);
5106
+ designerContext.state.onPreferencesChanged.subscribe(designer.onPreferencesChanged.emit);
5094
5107
  return designer;
5095
5108
  }
5096
5109
  constructor(view, state, walker, historyController, api) {
@@ -5131,6 +5144,10 @@ class Designer {
5131
5144
  * @description Fires when the root component and all its children are rerendered.
5132
5145
  */
5133
5146
  this.onRootComponentUpdated = new SimpleEvent();
5147
+ /**
5148
+ * @description Fires when the dragging state has changed. `true` if the step is being dragged, otherwise `false`.
5149
+ */
5150
+ this.onIsDraggingChanged = new SimpleEvent();
5134
5151
  /**
5135
5152
  * @description Fires when any of the designer preferences has changed.
5136
5153
  */
@@ -5240,6 +5257,12 @@ class Designer {
5240
5257
  isEditorCollapsed() {
5241
5258
  return this.state.isEditorCollapsed;
5242
5259
  }
5260
+ /**
5261
+ * @returns a flag that indicates whether the step is being dragged.
5262
+ */
5263
+ isDragging() {
5264
+ return this.state.isDragging;
5265
+ }
5243
5266
  /**
5244
5267
  * @description Sets a flag that indicates whether the editor is collapsed.
5245
5268
  */
package/lib/index.d.ts CHANGED
@@ -61,7 +61,7 @@ declare class SimpleEvent<T> {
61
61
  private readonly listeners;
62
62
  subscribe(listener: SimpleEventListener<T>): void;
63
63
  unsubscribe(listener: SimpleEventListener<T>): void;
64
- readonly forward: (value: T) => void;
64
+ readonly emit: (value: T) => void;
65
65
  count(): number;
66
66
  once(): Promise<T>;
67
67
  }
@@ -302,8 +302,9 @@ declare class ComponentContext {
302
302
  readonly services: Services;
303
303
  readonly preferenceStorage: PreferenceStorage;
304
304
  readonly i18n: I18n;
305
+ readonly textWidthMeasurer: TextWidthMeasurer;
305
306
  private readonly state;
306
- static create(configuration: DesignerConfiguration, state: DesignerState, stepExtensionResolver: StepExtensionResolver, placeholderController: PlaceholderController, definitionWalker: DefinitionWalker, preferenceStorage: PreferenceStorage, i18n: I18n, services: Services): ComponentContext;
307
+ static create(configuration: DesignerConfiguration, state: DesignerState, stepExtensionResolver: StepExtensionResolver, placeholderController: PlaceholderController, definitionWalker: DefinitionWalker, preferenceStorage: PreferenceStorage, i18n: I18n, textWidthMeasurer: TextWidthMeasurer, services: Services): ComponentContext;
307
308
  private constructor();
308
309
  getViewportScale(): number;
309
310
  }
@@ -592,7 +593,7 @@ declare class LabelView {
592
593
  readonly g: SVGGElement;
593
594
  readonly width: number;
594
595
  readonly height: number;
595
- static create(parent: SVGElement, y: number, cfg: LabelViewConfiguration, text: string, theme: 'primary' | 'secondary'): LabelView;
596
+ static create(parent: SVGElement, y: number, cfg: LabelViewConfiguration, text: string, theme: 'primary' | 'secondary', textWidthMeasurer: TextWidthMeasurer): LabelView;
596
597
  constructor(g: SVGGElement, width: number, height: number);
597
598
  }
598
599
 
@@ -873,6 +874,7 @@ interface StepExtension<S extends Step = Step> {
873
874
  type StepComponentViewFactory = StepExtension['createComponentView'];
874
875
  interface StepComponentViewContext {
875
876
  i18n: I18n;
877
+ textWidthMeasurer: TextWidthMeasurer;
876
878
  getStepName(): string;
877
879
  getStepIconUrl(): string | null;
878
880
  createStepComponent(parentElement: SVGElement, parentSequence: Sequence, step: Step, position: number): StepComponent;
@@ -1094,6 +1096,10 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
1094
1096
  * @description Custom translation function.
1095
1097
  */
1096
1098
  i18n?: I18n;
1099
+ /**
1100
+ * @description Custom text width measurer. By default, the designer uses `getBBox()` method to measure the width of the text.
1101
+ */
1102
+ textWidthMeasurer?: TextWidthMeasurer;
1097
1103
  /**
1098
1104
  * @description Pass the shadow root of the shadow root to the designer if the designer is placed inside the shadow DOM.
1099
1105
  */
@@ -1149,6 +1155,7 @@ interface PreferenceStorage {
1149
1155
  setItem(key: string, value: string): void;
1150
1156
  getItem(key: string): string | null;
1151
1157
  }
1158
+ type TextWidthMeasurer = (text: SVGTextElement) => number;
1152
1159
  interface StepsConfiguration {
1153
1160
  isSelectable?: (step: Step, parentSequence: Sequence) => boolean;
1154
1161
  isDraggable?: (step: Step, parentSequence: Sequence) => boolean;
@@ -1391,6 +1398,10 @@ declare class Designer<TDefinition extends Definition = Definition> {
1391
1398
  * @description Fires when the root component and all its children are rerendered.
1392
1399
  */
1393
1400
  readonly onRootComponentUpdated: SimpleEvent<void>;
1401
+ /**
1402
+ * @description Fires when the dragging state has changed. `true` if the step is being dragged, otherwise `false`.
1403
+ */
1404
+ readonly onIsDraggingChanged: SimpleEvent<boolean>;
1394
1405
  /**
1395
1406
  * @description Fires when any of the designer preferences has changed.
1396
1407
  */
@@ -1464,6 +1475,10 @@ declare class Designer<TDefinition extends Definition = Definition> {
1464
1475
  * @returns a flag that indicates whether the editor is collapsed.
1465
1476
  */
1466
1477
  isEditorCollapsed(): boolean;
1478
+ /**
1479
+ * @returns a flag that indicates whether the step is being dragged.
1480
+ */
1481
+ isDragging(): boolean;
1467
1482
  /**
1468
1483
  * @description Sets a flag that indicates whether the editor is collapsed.
1469
1484
  */
@@ -1494,4 +1509,4 @@ declare class Designer<TDefinition extends Definition = Definition> {
1494
1509
  }
1495
1510
 
1496
1511
  export { Badges, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommandType, ComponentContext, ComponentDom, ControlBarApi, CustomActionController, DefaultRegionComponentViewExtension, DefaultRegionView, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerDesignerExtension, DefaultViewportControllerExtension, DefinitionChangeType, Designer, DesignerApi, DesignerContext, DesignerState, Dom, Editor, EditorApi, Icons, InputView, JoinView, KeyboardAction, LabelView, LineGridDesignerExtension, ObjectCloner, OutputView, PathBarApi, PlaceholderController, PlaceholderDirection, PlaceholderGapOrientation, RectPlaceholder, RectPlaceholderDesignerExtension, RectPlaceholderView, SelectStepBehaviorEndToken, ServicesResolver, SimpleEvent, StartStopRootComponentDesignerExtension, StartStopRootComponentExtension, StepComponent, StepExtensionResolver, StepsDesignerExtension, TYPE, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, ViewportApi, WorkspaceApi, createContainerStepComponentViewFactory, createLaunchPadStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
1497
- export type { Attributes, Badge, BadgeExtension, BadgeView, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, BranchNameLabelResolver, BranchNamesResolver, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickDetails, Component, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultViewportControllerConfiguration, DefaultViewportControllerExtensionConfiguration, DefinitionChangedEvent, DefinitionChangedEventDetails, DesignerConfiguration, DesignerExtension, DraggedComponent, DraggedComponentExtension, DuplicatedStepId, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, KeyboardConfiguration, LaunchPadStepComponentViewConfiguration, LaunchPadStepExtensionConfiguration, LineGridConfiguration, NextScale, OpenFolderClickCommand, Placeholder, PlaceholderConfiguration, PlaceholderExtension, PlaceholderView, PreferenceChange, PreferenceStorage, PreferencesChangedEvent, RectPlaceholderConfiguration, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, SetPreferencesClickCommand, SimpleEventListener, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceRootSequence };
1512
+ export type { Attributes, Badge, BadgeExtension, BadgeView, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, BranchNameLabelResolver, BranchNamesResolver, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickDetails, Component, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultViewportControllerConfiguration, DefaultViewportControllerExtensionConfiguration, DefinitionChangedEvent, DefinitionChangedEventDetails, DesignerConfiguration, DesignerExtension, DraggedComponent, DraggedComponentExtension, DuplicatedStepId, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, KeyboardConfiguration, LaunchPadStepComponentViewConfiguration, LaunchPadStepExtensionConfiguration, LineGridConfiguration, NextScale, OpenFolderClickCommand, Placeholder, PlaceholderConfiguration, PlaceholderExtension, PlaceholderView, PreferenceChange, PreferenceStorage, PreferencesChangedEvent, RectPlaceholderConfiguration, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, SetPreferencesClickCommand, SimpleEventListener, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, TextWidthMeasurer, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceRootSequence };
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.37.3",
4
+ "version": "0.38.0",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",