sequential-workflow-designer 0.29.2 → 0.30.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/dist/index.umd.js CHANGED
@@ -442,13 +442,16 @@
442
442
  const scroll = new Vector(window.scrollX, window.scrollY);
443
443
  this.cache = this.placeholders.map(placeholder => {
444
444
  const rect = placeholder.getClientRect();
445
+ const lt = new Vector(rect.x, rect.y).add(scroll);
446
+ const br = new Vector(rect.x + rect.width, rect.y + rect.height).add(scroll);
445
447
  return {
446
448
  placeholder,
447
- lt: new Vector(rect.x, rect.y).add(scroll),
448
- br: new Vector(rect.x + rect.width, rect.y + rect.height).add(scroll)
449
+ lt,
450
+ br,
451
+ diagSq: lt.x * lt.x + lt.y * lt.y
449
452
  };
450
453
  });
451
- this.cache.sort((a, b) => a.lt.y - b.lt.y);
454
+ this.cache.sort((a, b) => a.diagSq - b.diagSq);
452
455
  }
453
456
  const vR = vLt.x + vWidth;
454
457
  const vB = vLt.y + vHeight;
@@ -600,7 +603,7 @@
600
603
  }
601
604
  activateStep(step) {
602
605
  const newStep = ObjectCloner.deepClone(step);
603
- newStep.id = this.uidGenerator ? this.uidGenerator() : Uid.next();
606
+ newStep.id = this.uidGenerator();
604
607
  return newStep;
605
608
  }
606
609
  }
@@ -615,9 +618,9 @@
615
618
  }
616
619
 
617
620
  class ToolboxDataProvider {
618
- constructor(iconProvider, i18n, configuration) {
619
- this.iconProvider = iconProvider;
621
+ constructor(i18n, iconProvider, configuration) {
620
622
  this.i18n = i18n;
623
+ this.iconProvider = iconProvider;
621
624
  this.configuration = configuration;
622
625
  this.createItemData = (step) => {
623
626
  StepTypeValidator.validate(step.type);
@@ -1005,8 +1008,8 @@
1005
1008
  static create(context) {
1006
1009
  const workspace = new WorkspaceApi(context.state, context.definitionWalker, context.workspaceController);
1007
1010
  const viewportController = context.services.viewportController.create(workspace);
1008
- const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
1009
- return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
1011
+ const toolboxDataProvider = new ToolboxDataProvider(context.i18n, context.componentContext.iconProvider, context.configuration.toolbox);
1012
+ return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
1010
1013
  }
1011
1014
  constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
1012
1015
  this.shadowRoot = shadowRoot;
@@ -1194,7 +1197,7 @@
1194
1197
  }
1195
1198
  }
1196
1199
 
1197
- const defaultConfiguration$7 = {
1200
+ const defaultConfiguration$6 = {
1198
1201
  view: {
1199
1202
  size: 22,
1200
1203
  iconSize: 12
@@ -1202,7 +1205,7 @@
1202
1205
  };
1203
1206
  class ValidationErrorBadgeExtension {
1204
1207
  static create(configuration) {
1205
- return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
1208
+ return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
1206
1209
  }
1207
1210
  constructor(configuration) {
1208
1211
  this.configuration = configuration;
@@ -1292,7 +1295,7 @@
1292
1295
  switch (targets.length) {
1293
1296
  case 1:
1294
1297
  if (start.x === targets[0].x) {
1295
- JoinView.createStraightJoin(parent, start, firstTarget.y * dy);
1298
+ JoinView.createStraightJoin(parent, start, h * 2 * dy);
1296
1299
  }
1297
1300
  else {
1298
1301
  appendCurvedJoins(parent, start, targets, h, dy);
@@ -1388,10 +1391,18 @@
1388
1391
  }
1389
1392
  }
1390
1393
 
1394
+ // PlaceholderExtension
1395
+ exports.PlaceholderGapOrientation = void 0;
1396
+ (function (PlaceholderGapOrientation) {
1397
+ PlaceholderGapOrientation[PlaceholderGapOrientation["along"] = 0] = "along";
1398
+ PlaceholderGapOrientation[PlaceholderGapOrientation["perpendicular"] = 1] = "perpendicular"; // Goes perpendicular to the flow
1399
+ })(exports.PlaceholderGapOrientation || (exports.PlaceholderGapOrientation = {}));
1400
+
1391
1401
  class DefaultSequenceComponentView {
1392
1402
  static create(parent, sequenceContext, componentContext) {
1393
- const phWidth = componentContext.services.placeholder.gapSize.x;
1394
- const phHeight = componentContext.services.placeholder.gapSize.y;
1403
+ const phSize = componentContext.services.placeholder.getGapSize(exports.PlaceholderGapOrientation.along);
1404
+ const phWidth = phSize.x;
1405
+ const phHeight = phSize.y;
1395
1406
  const { sequence } = sequenceContext;
1396
1407
  const g = Dom.svg('g');
1397
1408
  parent.appendChild(g);
@@ -1428,7 +1439,7 @@
1428
1439
  JoinView.createStraightJoin(g, new Vector(joinX, offsetY - phHeight), phHeight);
1429
1440
  }
1430
1441
  if (!sequenceContext.isPreview && componentContext.placeholderController.canCreate(sequence, i)) {
1431
- const ph = componentContext.services.placeholder.createForGap(g, sequence, i);
1442
+ const ph = componentContext.services.placeholder.createForGap(g, sequence, i, exports.PlaceholderGapOrientation.along);
1432
1443
  Dom.translate(ph.view.g, joinX - phWidth / 2, offsetY - phHeight);
1433
1444
  placeholders.push(ph);
1434
1445
  }
@@ -1440,7 +1451,7 @@
1440
1451
  }
1441
1452
  const newIndex = components.length;
1442
1453
  if (!sequenceContext.isPreview && componentContext.placeholderController.canCreate(sequence, newIndex)) {
1443
- const ph = componentContext.services.placeholder.createForGap(g, sequence, newIndex);
1454
+ const ph = componentContext.services.placeholder.createForGap(g, sequence, newIndex, exports.PlaceholderGapOrientation.along);
1444
1455
  Dom.translate(ph.view.g, joinX - phWidth / 2, offsetY - phHeight);
1445
1456
  placeholders.push(ph);
1446
1457
  }
@@ -1488,21 +1499,19 @@
1488
1499
  }
1489
1500
  findById(stepId) {
1490
1501
  for (const component of this.view.components) {
1491
- const sc = component.findById(stepId);
1492
- if (sc) {
1493
- return sc;
1502
+ const result = component.findById(stepId);
1503
+ if (result) {
1504
+ return result;
1494
1505
  }
1495
1506
  }
1496
1507
  return null;
1497
1508
  }
1498
1509
  resolvePlaceholders(skipComponent, result) {
1510
+ this.view.components.forEach(component => component.resolvePlaceholders(skipComponent, result));
1499
1511
  this.view.placeholders.forEach(placeholder => result.placeholders.push(placeholder));
1500
- this.view.components.forEach(c => c.resolvePlaceholders(skipComponent, result));
1501
1512
  }
1502
1513
  updateBadges(result) {
1503
- for (const component of this.view.components) {
1504
- component.updateBadges(result);
1505
- }
1514
+ this.view.components.forEach(component => component.updateBadges(result));
1506
1515
  }
1507
1516
  }
1508
1517
 
@@ -1515,7 +1524,7 @@
1515
1524
  })(exports.ClickCommandType || (exports.ClickCommandType = {}));
1516
1525
  exports.PlaceholderDirection = void 0;
1517
1526
  (function (PlaceholderDirection) {
1518
- PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
1527
+ PlaceholderDirection[PlaceholderDirection["gap"] = 0] = "gap";
1519
1528
  PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
1520
1529
  PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
1521
1530
  })(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
@@ -1529,7 +1538,7 @@
1529
1538
  const sequenceComponent = DefaultSequenceComponent.create(g, {
1530
1539
  sequence,
1531
1540
  depth: 0,
1532
- isInputConnected: true,
1541
+ isInputConnected: Boolean(cfg.start),
1533
1542
  isOutputConnected: true,
1534
1543
  isPreview: false
1535
1544
  }, context);
@@ -1537,9 +1546,11 @@
1537
1546
  const x = view.joinX - cfg.size / 2;
1538
1547
  const endY = cfg.size + view.height;
1539
1548
  const iconSize = parentPlaceIndicator ? cfg.folderIconSize : cfg.defaultIconSize;
1540
- const startCircle = createCircle('start', parentPlaceIndicator ? cfg.folderIconD : cfg.startIconD, cfg.size, iconSize);
1541
- Dom.translate(startCircle, x, 0);
1542
- g.appendChild(startCircle);
1549
+ if (cfg.start) {
1550
+ const startCircle = createCircle('start', parentPlaceIndicator ? cfg.folderIconD : cfg.start.iconD, cfg.size, iconSize);
1551
+ Dom.translate(startCircle, x, 0);
1552
+ g.appendChild(startCircle);
1553
+ }
1543
1554
  Dom.translate(view.g, 0, cfg.size);
1544
1555
  const stopCircle = createCircle('stop', parentPlaceIndicator ? cfg.folderIconD : cfg.stopIconD, cfg.size, iconSize);
1545
1556
  Dom.translate(stopCircle, x, endY);
@@ -1616,31 +1627,33 @@
1616
1627
  }
1617
1628
  }
1618
1629
 
1619
- const defaultConfiguration$6 = {
1620
- view: {
1621
- size: 30,
1622
- defaultIconSize: 22,
1623
- folderIconSize: 18,
1624
- startIconD: Icons.play,
1625
- stopIconD: Icons.stop,
1626
- folderIconD: Icons.folder
1627
- }
1630
+ const defaultViewConfiguration$1 = {
1631
+ size: 30,
1632
+ defaultIconSize: 22,
1633
+ folderIconSize: 18,
1634
+ start: {
1635
+ iconD: Icons.play
1636
+ },
1637
+ stopIconD: Icons.stop,
1638
+ folderIconD: Icons.folder
1628
1639
  };
1629
1640
  class StartStopRootComponentExtension {
1630
1641
  static create(configuration) {
1631
- return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
1642
+ return new StartStopRootComponentExtension(configuration);
1632
1643
  }
1633
1644
  constructor(configuration) {
1634
1645
  this.configuration = configuration;
1635
1646
  }
1636
1647
  create(parentElement, sequence, parentPlaceIndicator, context) {
1637
- return StartStopRootComponent.create(parentElement, sequence, parentPlaceIndicator, context, this.configuration.view);
1648
+ var _a;
1649
+ const view = ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.view) ? Object.assign(Object.assign({}, defaultViewConfiguration$1), this.configuration.view) : defaultViewConfiguration$1;
1650
+ return StartStopRootComponent.create(parentElement, sequence, parentPlaceIndicator, context, view);
1638
1651
  }
1639
1652
  }
1640
1653
 
1641
- const COMPONENT_CLASS_NAME$2 = 'container';
1654
+ const COMPONENT_CLASS_NAME$3 = 'container';
1642
1655
  const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepContext, viewContext) => {
1643
- return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$2, (g, regionViewBuilder) => {
1656
+ return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
1644
1657
  const step = stepContext.step;
1645
1658
  const name = viewContext.getStepName();
1646
1659
  const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary');
@@ -1666,7 +1679,7 @@
1666
1679
  height,
1667
1680
  joinX,
1668
1681
  placeholders: null,
1669
- sequenceComponents: [sequenceComponent],
1682
+ components: [sequenceComponent],
1670
1683
  hasOutput: sequenceComponent.hasOutput,
1671
1684
  getClientPosition() {
1672
1685
  return regionView.getClientPosition();
@@ -1690,6 +1703,149 @@
1690
1703
  });
1691
1704
  };
1692
1705
 
1706
+ const COMPONENT_CLASS_NAME$2 = 'launch-pad';
1707
+ function createView$1(parentElement, stepContext, viewContext, regionViewFactory, isInterruptedIfEmpty, cfg) {
1708
+ const step = stepContext.step;
1709
+ const sequence = stepContext.step.sequence;
1710
+ const g = ComponentDom.stepG(COMPONENT_CLASS_NAME$2, step.type, step.id);
1711
+ parentElement.appendChild(g);
1712
+ const components = [];
1713
+ let width;
1714
+ let height;
1715
+ let joinX;
1716
+ const placeholdersX = [];
1717
+ let placeholderOrientation;
1718
+ let placeholderSize;
1719
+ let hasOutput;
1720
+ let inputView = null;
1721
+ let outputView = null;
1722
+ if (sequence.length > 0) {
1723
+ let maxComponentHeight = 0;
1724
+ for (let i = 0; i < sequence.length; i++) {
1725
+ const component = viewContext.createStepComponent(g, sequence, sequence[i], i);
1726
+ components.push(component);
1727
+ maxComponentHeight = Math.max(maxComponentHeight, component.view.height);
1728
+ }
1729
+ const joinsX = [];
1730
+ const positionsX = [];
1731
+ const spacesY = [];
1732
+ placeholderOrientation = exports.PlaceholderGapOrientation.perpendicular;
1733
+ placeholderSize = viewContext.getPlaceholderGapSize(placeholderOrientation);
1734
+ placeholdersX.push(0);
1735
+ let positionX = placeholderSize.x;
1736
+ for (let i = 0; i < components.length; i++) {
1737
+ if (i > 0) {
1738
+ placeholdersX.push(positionX);
1739
+ positionX += placeholderSize.x;
1740
+ }
1741
+ const component = components[i];
1742
+ const componentY = (maxComponentHeight - component.view.height) / 2 + cfg.connectionHeight + cfg.paddingY;
1743
+ Dom.translate(component.view.g, positionX, componentY);
1744
+ joinsX.push(positionX + component.view.joinX);
1745
+ positionX += component.view.width;
1746
+ positionsX.push(positionX);
1747
+ spacesY.push(Math.max(0, (maxComponentHeight - component.view.height) / 2));
1748
+ }
1749
+ placeholdersX.push(positionX);
1750
+ positionX += placeholderSize.x;
1751
+ width = positionX;
1752
+ height = maxComponentHeight + 2 * cfg.connectionHeight + 2 * cfg.paddingY;
1753
+ const contentJoinX = components.length % 2 === 0
1754
+ ? positionsX[Math.max(0, Math.floor(components.length / 2) - 1)] + placeholderSize.x / 2
1755
+ : joinsX[Math.floor(components.length / 2)];
1756
+ if (stepContext.isInputConnected) {
1757
+ const joinsTopY = joinsX.map(x => new Vector(x, cfg.connectionHeight));
1758
+ JoinView.createJoins(g, new Vector(contentJoinX, 0), joinsTopY);
1759
+ for (let i = 0; i < joinsX.length; i++) {
1760
+ JoinView.createStraightJoin(g, joinsTopY[i], cfg.paddingY + spacesY[i]);
1761
+ }
1762
+ }
1763
+ const joinsBottomY = joinsX.map(x => new Vector(x, cfg.connectionHeight + 2 * cfg.paddingY + maxComponentHeight));
1764
+ JoinView.createJoins(g, new Vector(contentJoinX, height), joinsBottomY);
1765
+ for (let i = 0; i < joinsX.length; i++) {
1766
+ JoinView.createStraightJoin(g, joinsBottomY[i], -(cfg.paddingY + spacesY[i]));
1767
+ }
1768
+ hasOutput = true;
1769
+ joinX = contentJoinX;
1770
+ }
1771
+ else {
1772
+ placeholderOrientation = exports.PlaceholderGapOrientation.along;
1773
+ placeholderSize = viewContext.getPlaceholderGapSize(placeholderOrientation);
1774
+ placeholdersX.push(cfg.emptyPaddingX);
1775
+ width = placeholderSize.x + cfg.emptyPaddingX * 2;
1776
+ height = placeholderSize.y + cfg.emptyPaddingY * 2;
1777
+ hasOutput = !isInterruptedIfEmpty;
1778
+ if (stepContext.isInputConnected) {
1779
+ inputView = InputView.createRoundInput(g, width / 2, 0, cfg.emptyInputSize);
1780
+ }
1781
+ if (stepContext.isOutputConnected && hasOutput) {
1782
+ outputView = OutputView.create(g, width / 2, height, cfg.emptyOutputSize);
1783
+ }
1784
+ if (cfg.emptyIconSize > 0) {
1785
+ const iconUrl = viewContext.getStepIconUrl();
1786
+ if (iconUrl) {
1787
+ const icon = Dom.svg('image', {
1788
+ href: iconUrl,
1789
+ x: (width - cfg.emptyIconSize) / 2,
1790
+ y: (height - cfg.emptyIconSize) / 2,
1791
+ width: cfg.emptyIconSize,
1792
+ height: cfg.emptyIconSize
1793
+ });
1794
+ g.appendChild(icon);
1795
+ }
1796
+ }
1797
+ joinX = width / 2;
1798
+ }
1799
+ let regionView = null;
1800
+ if (regionViewFactory) {
1801
+ regionView = regionViewFactory(g, [width], height);
1802
+ }
1803
+ const placeholders = [];
1804
+ const placeholderY = (height - placeholderSize.y) / 2;
1805
+ for (let i = 0; i < placeholdersX.length; i++) {
1806
+ const placeholder = viewContext.createPlaceholderForGap(g, sequence, i, placeholderOrientation);
1807
+ placeholders.push(placeholder);
1808
+ Dom.translate(placeholder.view.g, placeholdersX[i], placeholderY);
1809
+ }
1810
+ return {
1811
+ g,
1812
+ width,
1813
+ height,
1814
+ joinX,
1815
+ components,
1816
+ placeholders,
1817
+ hasOutput,
1818
+ getClientPosition() {
1819
+ return getAbsolutePosition(g);
1820
+ },
1821
+ resolveClick(click) {
1822
+ if (regionView) {
1823
+ const result = regionView.resolveClick(click);
1824
+ return result === true || (result === null && g.contains(click.element)) ? true : result;
1825
+ }
1826
+ return null;
1827
+ },
1828
+ setIsDragging(isDragging) {
1829
+ inputView === null || inputView === void 0 ? void 0 : inputView.setIsHidden(isDragging);
1830
+ outputView === null || outputView === void 0 ? void 0 : outputView.setIsHidden(isDragging);
1831
+ },
1832
+ setIsDisabled(isDisabled) {
1833
+ Dom.toggleClass(g, isDisabled, 'sqd-disabled');
1834
+ },
1835
+ setIsSelected(isSelected) {
1836
+ regionView === null || regionView === void 0 ? void 0 : regionView.setIsSelected(isSelected);
1837
+ }
1838
+ };
1839
+ }
1840
+ const createLaunchPadStepComponentViewFactory = (isInterruptedIfEmpty, cfg) => (parentElement, stepContext, viewContext) => {
1841
+ if (cfg.isRegionEnabled) {
1842
+ return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$2, (g, regionViewBuilder) => {
1843
+ return createView$1(g, stepContext, viewContext, regionViewBuilder, isInterruptedIfEmpty, cfg);
1844
+ });
1845
+ }
1846
+ return createView$1(parentElement, stepContext, viewContext, null, isInterruptedIfEmpty, cfg);
1847
+ };
1848
+
1693
1849
  const COMPONENT_CLASS_NAME$1 = 'switch';
1694
1850
  function createView(g, width, height, joinX, viewContext, sequenceComponents, regionView, cfg) {
1695
1851
  let inputView = null;
@@ -1703,7 +1859,7 @@
1703
1859
  height,
1704
1860
  joinX,
1705
1861
  placeholders: null,
1706
- sequenceComponents,
1862
+ components: sequenceComponents,
1707
1863
  hasOutput: sequenceComponents ? sequenceComponents.some(c => c.hasOutput) : true,
1708
1864
  getClientPosition() {
1709
1865
  return regionView.getClientPosition();
@@ -1854,7 +2010,7 @@
1854
2010
  height: cfg.iconSize
1855
2011
  });
1856
2012
  g.appendChild(icon);
1857
- const isInputViewHidden = stepContext.depth === 0 && stepContext.position === 0 && !stepContext.isInputConnected;
2013
+ const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
1858
2014
  const isOutputViewHidden = isInterrupted;
1859
2015
  const inputView = isInputViewHidden ? null : InputView.createRoundInput(g, boxWidth / 2, 0, cfg.inputSize);
1860
2016
  const outputView = isOutputViewHidden ? null : OutputView.create(g, boxWidth / 2, boxHeight, cfg.outputSize);
@@ -1863,7 +2019,7 @@
1863
2019
  width: boxWidth,
1864
2020
  height: boxHeight,
1865
2021
  joinX: boxWidth / 2,
1866
- sequenceComponents: null,
2022
+ components: null,
1867
2023
  placeholders: null,
1868
2024
  hasOutput: !!outputView,
1869
2025
  getClientPosition() {
@@ -2038,8 +2194,8 @@
2038
2194
  if (this.step.id === stepId) {
2039
2195
  return this;
2040
2196
  }
2041
- if (this.view.sequenceComponents) {
2042
- for (const component of this.view.sequenceComponents) {
2197
+ if (this.view.components) {
2198
+ for (const component of this.view.components) {
2043
2199
  const result = component.findById(stepId);
2044
2200
  if (result) {
2045
2201
  return result;
@@ -2049,14 +2205,22 @@
2049
2205
  return null;
2050
2206
  }
2051
2207
  resolveClick(click) {
2052
- if (this.view.sequenceComponents) {
2053
- for (const component of this.view.sequenceComponents) {
2208
+ if (this.view.components) {
2209
+ for (const component of this.view.components) {
2054
2210
  const result = component.resolveClick(click);
2055
2211
  if (result) {
2056
2212
  return result;
2057
2213
  }
2058
2214
  }
2059
2215
  }
2216
+ if (this.view.placeholders) {
2217
+ for (const placeholder of this.view.placeholders) {
2218
+ const result = placeholder.resolveClick(click);
2219
+ if (result) {
2220
+ return result;
2221
+ }
2222
+ }
2223
+ }
2060
2224
  const badgeResult = this.badges.resolveClick(click);
2061
2225
  if (badgeResult) {
2062
2226
  return badgeResult;
@@ -2074,8 +2238,8 @@
2074
2238
  }
2075
2239
  resolvePlaceholders(skipComponent, result) {
2076
2240
  if (skipComponent !== this) {
2077
- if (this.view.sequenceComponents) {
2078
- this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
2241
+ if (this.view.components) {
2242
+ this.view.components.forEach(component => component.resolvePlaceholders(skipComponent, result));
2079
2243
  }
2080
2244
  if (this.view.placeholders) {
2081
2245
  this.view.placeholders.forEach(ph => result.placeholders.push(ph));
@@ -2093,8 +2257,8 @@
2093
2257
  this.view.setIsDisabled(isDisabled);
2094
2258
  }
2095
2259
  updateBadges(result) {
2096
- if (this.view.sequenceComponents) {
2097
- this.view.sequenceComponents.forEach(component => component.updateBadges(result));
2260
+ if (this.view.components) {
2261
+ this.view.components.forEach(component => component.updateBadges(result));
2098
2262
  }
2099
2263
  this.badges.update(result);
2100
2264
  }
@@ -2121,6 +2285,18 @@
2121
2285
  }
2122
2286
  }
2123
2287
 
2288
+ class PlaceholderController {
2289
+ static create(configuration) {
2290
+ return new PlaceholderController(configuration);
2291
+ }
2292
+ constructor(configuration) {
2293
+ var _a, _b, _c, _d;
2294
+ this.configuration = configuration;
2295
+ this.canCreate = (_b = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.canCreate) !== null && _b !== void 0 ? _b : (() => true);
2296
+ this.canShow = (_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.canShow) !== null && _d !== void 0 ? _d : (() => true);
2297
+ }
2298
+ }
2299
+
2124
2300
  class RectPlaceholderView {
2125
2301
  static create(parent, width, height, radius, iconSize, direction) {
2126
2302
  const g = Dom.svg('g', {
@@ -2159,8 +2335,8 @@
2159
2335
  }
2160
2336
 
2161
2337
  class RectPlaceholder {
2162
- static create(parent, size, direction, sequence, index, configuration) {
2163
- const view = RectPlaceholderView.create(parent, size.x, size.y, configuration.radius, configuration.iconSize, direction);
2338
+ static create(parent, size, direction, sequence, index, radius, iconSize) {
2339
+ const view = RectPlaceholderView.create(parent, size.x, size.y, radius, iconSize, direction);
2164
2340
  return new RectPlaceholder(view, sequence, index);
2165
2341
  }
2166
2342
  constructor(view, parentSequence, index) {
@@ -2392,6 +2568,28 @@
2392
2568
  }
2393
2569
  }
2394
2570
 
2571
+ const defaultViewConfiguration = {
2572
+ isRegionEnabled: true,
2573
+ paddingY: 10,
2574
+ connectionHeight: 20,
2575
+ emptyPaddingX: 20,
2576
+ emptyPaddingY: 20,
2577
+ emptyInputSize: 14,
2578
+ emptyOutputSize: 10,
2579
+ emptyIconSize: 24
2580
+ };
2581
+ class LaunchPadStepExtension {
2582
+ static create(configuration) {
2583
+ return new LaunchPadStepExtension(configuration);
2584
+ }
2585
+ constructor(configuration) {
2586
+ var _a, _b;
2587
+ this.configuration = configuration;
2588
+ this.componentType = 'launchPad';
2589
+ this.createComponentView = createLaunchPadStepComponentViewFactory(false, (_b = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.view) !== null && _b !== void 0 ? _b : defaultViewConfiguration);
2590
+ }
2591
+ }
2592
+
2395
2593
  class StepsDesignerExtension {
2396
2594
  static create(configuration) {
2397
2595
  const steps = [];
@@ -2404,6 +2602,9 @@
2404
2602
  if (configuration.task) {
2405
2603
  steps.push(TaskStepExtension.create(configuration.task));
2406
2604
  }
2605
+ if (configuration.launchPad) {
2606
+ steps.push(LaunchPadStepExtension.create(configuration.launchPad));
2607
+ }
2407
2608
  return new StepsDesignerExtension(steps);
2408
2609
  }
2409
2610
  constructor(steps) {
@@ -2451,6 +2652,17 @@
2451
2652
  i18n: componentContext.i18n,
2452
2653
  getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
2453
2654
  getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
2655
+ createStepComponent: (parentElement, parentSequence, step, position) => {
2656
+ return componentContext.stepComponentFactory.create(parentElement, {
2657
+ parentSequence,
2658
+ step,
2659
+ depth: stepContext.depth + 1,
2660
+ position,
2661
+ isInputConnected: stepContext.isInputConnected,
2662
+ isOutputConnected: stepContext.isOutputConnected,
2663
+ isPreview: stepContext.isPreview
2664
+ }, componentContext);
2665
+ },
2454
2666
  createSequenceComponent: (parentElement, sequence) => {
2455
2667
  const sequenceContext = {
2456
2668
  sequence,
@@ -2464,6 +2676,8 @@
2464
2676
  createRegionComponentView(parentElement, componentClassName, contentFactory) {
2465
2677
  return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
2466
2678
  },
2679
+ getPlaceholderGapSize: orientation => componentContext.services.placeholder.getGapSize(orientation),
2680
+ createPlaceholderForGap: componentContext.services.placeholder.createForGap.bind(componentContext.services.placeholder),
2467
2681
  createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
2468
2682
  getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
2469
2683
  setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
@@ -2485,7 +2699,7 @@
2485
2699
  }
2486
2700
 
2487
2701
  class ComponentContext {
2488
- static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
2702
+ static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
2489
2703
  const validator = new DefinitionValidator(configuration.validator, state);
2490
2704
  const iconProvider = new IconProvider(configuration.steps);
2491
2705
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
@@ -2818,14 +3032,15 @@
2818
3032
  }
2819
3033
 
2820
3034
  class StateModifier {
2821
- static create(definitionWalker, state, configuration) {
3035
+ static create(definitionWalker, uidGenerator, state, configuration) {
2822
3036
  const dependencies = [];
2823
3037
  dependencies.push(new SelectedStepIdDefinitionModifierDependency(state, definitionWalker));
2824
3038
  dependencies.push(new FolderPathDefinitionModifierDependency(state, definitionWalker));
2825
- return new StateModifier(definitionWalker, state, configuration, dependencies);
3039
+ return new StateModifier(definitionWalker, uidGenerator, state, configuration, dependencies);
2826
3040
  }
2827
- constructor(definitionWalker, state, configuration, dependencies) {
3041
+ constructor(definitionWalker, uidGenerator, state, configuration, dependencies) {
2828
3042
  this.definitionWalker = definitionWalker;
3043
+ this.uidGenerator = uidGenerator;
2829
3044
  this.state = state;
2830
3045
  this.configuration = configuration;
2831
3046
  this.dependencies = dependencies;
@@ -2834,15 +3049,17 @@
2834
3049
  this.dependencies.push(dependency);
2835
3050
  }
2836
3051
  isSelectable(step, parentSequence) {
2837
- return this.configuration.steps.isSelectable ? this.configuration.steps.isSelectable(step, parentSequence) : true;
3052
+ return this.configuration.isSelectable ? this.configuration.isSelectable(step, parentSequence) : true;
2838
3053
  }
2839
3054
  trySelectStep(step, parentSequence) {
2840
3055
  if (this.isSelectable(step, parentSequence)) {
2841
3056
  this.state.setSelectedStepId(step.id);
3057
+ return true;
2842
3058
  }
3059
+ return false;
2843
3060
  }
2844
3061
  trySelectStepById(stepId) {
2845
- if (this.configuration.steps.isSelectable) {
3062
+ if (this.configuration.isSelectable) {
2846
3063
  const result = this.definitionWalker.getParentSequence(this.state.definition, stepId);
2847
3064
  this.trySelectStep(result.step, result.parentSequence);
2848
3065
  }
@@ -2851,16 +3068,16 @@
2851
3068
  }
2852
3069
  }
2853
3070
  isDeletable(stepId) {
2854
- if (this.configuration.steps.isDeletable) {
3071
+ if (this.configuration.isDeletable) {
2855
3072
  const result = this.definitionWalker.getParentSequence(this.state.definition, stepId);
2856
- return this.configuration.steps.isDeletable(result.step, result.parentSequence);
3073
+ return this.configuration.isDeletable(result.step, result.parentSequence);
2857
3074
  }
2858
3075
  return true;
2859
3076
  }
2860
3077
  tryDelete(stepId) {
2861
3078
  const result = this.definitionWalker.getParentSequence(this.state.definition, stepId);
2862
- const canDeleteStep = this.configuration.steps.canDeleteStep
2863
- ? this.configuration.steps.canDeleteStep(result.step, result.parentSequence)
3079
+ const canDeleteStep = this.configuration.canDeleteStep
3080
+ ? this.configuration.canDeleteStep(result.step, result.parentSequence)
2864
3081
  : true;
2865
3082
  if (!canDeleteStep) {
2866
3083
  return false;
@@ -2871,46 +3088,43 @@
2871
3088
  return true;
2872
3089
  }
2873
3090
  tryInsert(step, targetSequence, targetIndex) {
2874
- const canInsertStep = this.configuration.steps.canInsertStep
2875
- ? this.configuration.steps.canInsertStep(step, targetSequence, targetIndex)
2876
- : true;
3091
+ const canInsertStep = this.configuration.canInsertStep ? this.configuration.canInsertStep(step, targetSequence, targetIndex) : true;
2877
3092
  if (!canInsertStep) {
2878
3093
  return false;
2879
3094
  }
2880
3095
  SequenceModifier.insertStep(step, targetSequence, targetIndex);
2881
3096
  this.state.notifyDefinitionChanged(exports.DefinitionChangeType.stepInserted, step.id);
2882
- if (!this.configuration.steps.isAutoSelectDisabled) {
3097
+ if (!this.configuration.isAutoSelectDisabled) {
2883
3098
  this.trySelectStepById(step.id);
2884
3099
  }
2885
3100
  return true;
2886
3101
  }
2887
3102
  isDraggable(step, parentSequence) {
2888
- return this.configuration.steps.isDraggable ? this.configuration.steps.isDraggable(step, parentSequence) : true;
3103
+ return this.configuration.isDraggable ? this.configuration.isDraggable(step, parentSequence) : true;
2889
3104
  }
2890
3105
  tryMove(sourceSequence, step, targetSequence, targetIndex) {
2891
3106
  const apply = SequenceModifier.tryMoveStep(sourceSequence, step, targetSequence, targetIndex);
2892
3107
  if (!apply) {
2893
3108
  return false;
2894
3109
  }
2895
- const canMoveStep = this.configuration.steps.canMoveStep
2896
- ? this.configuration.steps.canMoveStep(sourceSequence, step, targetSequence, targetIndex)
3110
+ const canMoveStep = this.configuration.canMoveStep
3111
+ ? this.configuration.canMoveStep(sourceSequence, step, targetSequence, targetIndex)
2897
3112
  : true;
2898
3113
  if (!canMoveStep) {
2899
3114
  return false;
2900
3115
  }
2901
3116
  apply();
2902
3117
  this.state.notifyDefinitionChanged(exports.DefinitionChangeType.stepMoved, step.id);
2903
- if (!this.configuration.steps.isAutoSelectDisabled) {
3118
+ if (!this.configuration.isAutoSelectDisabled) {
2904
3119
  this.trySelectStep(step, targetSequence);
2905
3120
  }
2906
3121
  return true;
2907
3122
  }
2908
3123
  isDuplicable(step, parentSequence) {
2909
- return this.configuration.steps.isDuplicable ? this.configuration.steps.isDuplicable(step, parentSequence) : false;
3124
+ return this.configuration.isDuplicable ? this.configuration.isDuplicable(step, parentSequence) : false;
2910
3125
  }
2911
3126
  tryDuplicate(step, parentSequence) {
2912
- const uidGenerator = this.configuration.uidGenerator ? this.configuration.uidGenerator : Uid.next;
2913
- const duplicator = new StepDuplicator(uidGenerator, this.definitionWalker);
3127
+ const duplicator = new StepDuplicator(this.uidGenerator, this.definitionWalker);
2914
3128
  const index = parentSequence.indexOf(step);
2915
3129
  const newStep = duplicator.duplicate(step);
2916
3130
  return this.tryInsert(newStep, parentSequence, index + 1);
@@ -3156,7 +3370,7 @@
3156
3370
 
3157
3371
  class DesignerContext {
3158
3372
  static create(placeholder, startDefinition, configuration, services) {
3159
- var _a, _b, _c, _d, _e;
3373
+ var _a, _b, _c, _d, _e, _f;
3160
3374
  const definition = ObjectCloner.deepClone(startDefinition);
3161
3375
  const layoutController = new LayoutController(placeholder);
3162
3376
  const isReadonly = Boolean(configuration.isReadonly);
@@ -3165,22 +3379,23 @@
3165
3379
  const theme = configuration.theme || 'light';
3166
3380
  const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
3167
3381
  const workspaceController = new WorkspaceControllerWrapper();
3168
- const placeholderController = services.placeholderController.create();
3169
3382
  const behaviorController = BehaviorController.create(configuration.shadowRoot);
3170
3383
  const stepExtensionResolver = StepExtensionResolver.create(services);
3384
+ const placeholderController = PlaceholderController.create(configuration.placeholder);
3171
3385
  const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
3172
3386
  const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
3173
- const stateModifier = StateModifier.create(definitionWalker, state, configuration);
3387
+ const uidGenerator = (_e = configuration.uidGenerator) !== null && _e !== void 0 ? _e : Uid.next;
3388
+ const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
3174
3389
  const customActionController = new CustomActionController(configuration, state, stateModifier);
3175
3390
  let historyController = undefined;
3176
3391
  if (configuration.undoStackSize) {
3177
3392
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
3178
3393
  }
3179
- const preferenceStorage = (_e = configuration.preferenceStorage) !== null && _e !== void 0 ? _e : new MemoryPreferenceStorage();
3180
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services);
3181
- return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3394
+ const preferenceStorage = (_f = configuration.preferenceStorage) !== null && _f !== void 0 ? _f : new MemoryPreferenceStorage();
3395
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services);
3396
+ return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
3182
3397
  }
3183
- constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
3398
+ constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
3184
3399
  this.theme = theme;
3185
3400
  this.state = state;
3186
3401
  this.configuration = configuration;
@@ -3188,6 +3403,7 @@
3188
3403
  this.componentContext = componentContext;
3189
3404
  this.definitionWalker = definitionWalker;
3190
3405
  this.i18n = i18n;
3406
+ this.uidGenerator = uidGenerator;
3191
3407
  this.stateModifier = stateModifier;
3192
3408
  this.layoutController = layoutController;
3193
3409
  this.workspaceController = workspaceController;
@@ -3418,7 +3634,10 @@
3418
3634
  if (interrupt) {
3419
3635
  return;
3420
3636
  }
3421
- this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
3637
+ if (!this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence)) {
3638
+ // If we cannot select the step, we clear the selection.
3639
+ this.state.setSelectedStepId(null);
3640
+ }
3422
3641
  return new SelectStepBehaviorEndToken(this.pressedStepComponent.step.id, Date.now());
3423
3642
  }
3424
3643
  }
@@ -4704,14 +4923,6 @@
4704
4923
  }
4705
4924
  }
4706
4925
 
4707
- class DefaultPlaceholderControllerExtension {
4708
- create() {
4709
- return {
4710
- canCreate: () => true
4711
- };
4712
- }
4713
- }
4714
-
4715
4926
  const defaultConfiguration = {
4716
4927
  gapWidth: 88,
4717
4928
  gapHeight: 24,
@@ -4724,13 +4935,18 @@
4724
4935
  }
4725
4936
  constructor(configuration) {
4726
4937
  this.configuration = configuration;
4727
- this.gapSize = new Vector(this.configuration.gapWidth, this.configuration.gapHeight);
4938
+ this.alongGapSize = new Vector(defaultConfiguration.gapWidth, defaultConfiguration.gapHeight);
4939
+ this.perpendicularGapSize = new Vector(defaultConfiguration.gapHeight, defaultConfiguration.gapWidth);
4728
4940
  }
4729
- createForGap(parent, parentSequence, index) {
4730
- return RectPlaceholder.create(parent, this.gapSize, exports.PlaceholderDirection.none, parentSequence, index, this.configuration);
4941
+ getGapSize(orientation) {
4942
+ return orientation === exports.PlaceholderGapOrientation.perpendicular ? this.perpendicularGapSize : this.alongGapSize;
4943
+ }
4944
+ createForGap(parent, parentSequence, index, orientation) {
4945
+ const gapSize = this.getGapSize(orientation);
4946
+ return RectPlaceholder.create(parent, gapSize, exports.PlaceholderDirection.gap, parentSequence, index, this.configuration.radius, this.configuration.iconSize);
4731
4947
  }
4732
4948
  createForArea(parent, size, direction, parentSequence, index) {
4733
- return RectPlaceholder.create(parent, size, direction, parentSequence, index, this.configuration);
4949
+ return RectPlaceholder.create(parent, size, direction, parentSequence, index, this.configuration.radius, this.configuration.iconSize);
4734
4950
  }
4735
4951
  }
4736
4952
 
@@ -4799,9 +5015,6 @@
4799
5015
  if (ext.wheelController) {
4800
5016
  services.wheelController = ext.wheelController;
4801
5017
  }
4802
- if (ext.placeholderController) {
4803
- services.placeholderController = ext.placeholderController;
4804
- }
4805
5018
  if (ext.placeholder) {
4806
5019
  services.placeholder = ext.placeholder;
4807
5020
  }
@@ -4835,6 +5048,7 @@
4835
5048
  services.steps.push(ContainerStepExtension.create());
4836
5049
  services.steps.push(SwitchStepExtension.create());
4837
5050
  services.steps.push(TaskStepExtension.create());
5051
+ services.steps.push(LaunchPadStepExtension.create());
4838
5052
  if (!services.stepComponentViewWrapper) {
4839
5053
  services.stepComponentViewWrapper = new DefaultStepComponentViewWrapperExtension();
4840
5054
  }
@@ -4868,9 +5082,6 @@
4868
5082
  if (!services.wheelController) {
4869
5083
  services.wheelController = new ClassicWheelControllerExtension();
4870
5084
  }
4871
- if (!services.placeholderController) {
4872
- services.placeholderController = new DefaultPlaceholderControllerExtension();
4873
- }
4874
5085
  if (!services.placeholder) {
4875
5086
  services.placeholder = RectPlaceholderExtension.create();
4876
5087
  }
@@ -5170,6 +5381,7 @@
5170
5381
  exports.ObjectCloner = ObjectCloner;
5171
5382
  exports.OutputView = OutputView;
5172
5383
  exports.PathBarApi = PathBarApi;
5384
+ exports.PlaceholderController = PlaceholderController;
5173
5385
  exports.RectPlaceholder = RectPlaceholder;
5174
5386
  exports.RectPlaceholderView = RectPlaceholderView;
5175
5387
  exports.SelectStepBehaviorEndToken = SelectStepBehaviorEndToken;
@@ -5188,6 +5400,7 @@
5188
5400
  exports.ViewportApi = ViewportApi;
5189
5401
  exports.WorkspaceApi = WorkspaceApi;
5190
5402
  exports.createContainerStepComponentViewFactory = createContainerStepComponentViewFactory;
5403
+ exports.createLaunchPadStepComponentViewFactory = createLaunchPadStepComponentViewFactory;
5191
5404
  exports.createSwitchStepComponentViewFactory = createSwitchStepComponentViewFactory;
5192
5405
  exports.createTaskStepComponentViewFactory = createTaskStepComponentViewFactory;
5193
5406
  exports.getAbsolutePosition = getAbsolutePosition;