sequential-workflow-designer 0.19.4 → 0.21.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 +5 -4
- package/dist/index.umd.js +320 -243
- package/lib/cjs/index.cjs +320 -243
- package/lib/esm/index.js +319 -243
- package/lib/index.d.ts +61 -18
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -600,13 +600,15 @@ class StepTypeValidator {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
class ToolboxDataProvider {
|
|
603
|
-
constructor(iconProvider, configuration) {
|
|
603
|
+
constructor(iconProvider, i18n, configuration) {
|
|
604
604
|
this.iconProvider = iconProvider;
|
|
605
|
+
this.i18n = i18n;
|
|
605
606
|
this.configuration = configuration;
|
|
606
607
|
this.createItemData = (step) => {
|
|
607
608
|
StepTypeValidator.validate(step.type);
|
|
608
609
|
const iconUrl = this.iconProvider.getIconUrl(step);
|
|
609
|
-
const
|
|
610
|
+
const rawLabel = this.configuration && this.configuration.labelProvider ? this.configuration.labelProvider(step) : step.name;
|
|
611
|
+
const label = this.i18n(`toolbox.item.${step.type}.label`, rawLabel);
|
|
610
612
|
const description = this.configuration && this.configuration.descriptionProvider ? this.configuration.descriptionProvider(step) : label;
|
|
611
613
|
const lowerCaseLabel = label.toLowerCase();
|
|
612
614
|
return {
|
|
@@ -704,10 +706,10 @@ class DesignerApi {
|
|
|
704
706
|
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
705
707
|
const viewportController = context.services.viewportController.create(workspace);
|
|
706
708
|
const viewport = new ViewportApi(context.workspaceController, viewportController);
|
|
707
|
-
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.configuration.toolbox);
|
|
708
|
-
return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker);
|
|
709
|
+
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
710
|
+
return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
709
711
|
}
|
|
710
|
-
constructor(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker) {
|
|
712
|
+
constructor(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
|
|
711
713
|
this.controlBar = controlBar;
|
|
712
714
|
this.toolbox = toolbox;
|
|
713
715
|
this.editor = editor;
|
|
@@ -715,6 +717,7 @@ class DesignerApi {
|
|
|
715
717
|
this.viewport = viewport;
|
|
716
718
|
this.pathBar = pathBar;
|
|
717
719
|
this.definitionWalker = definitionWalker;
|
|
720
|
+
this.i18n = i18n;
|
|
718
721
|
}
|
|
719
722
|
}
|
|
720
723
|
|
|
@@ -755,7 +758,7 @@ const BADGE_GAP = 4;
|
|
|
755
758
|
class Badges {
|
|
756
759
|
static createForStep(stepContext, view, componentContext) {
|
|
757
760
|
const g = createG(view.g);
|
|
758
|
-
const badges = componentContext.services.badges.map(ext => ext.createForStep(g, stepContext, componentContext));
|
|
761
|
+
const badges = componentContext.services.badges.map(ext => ext.createForStep(g, view, stepContext, componentContext));
|
|
759
762
|
const position = new Vector(view.width, 0);
|
|
760
763
|
return new Badges(g, position, badges);
|
|
761
764
|
}
|
|
@@ -829,7 +832,7 @@ exports.PlaceholderDirection = void 0;
|
|
|
829
832
|
class StepComponent {
|
|
830
833
|
static create(view, stepContext, componentContext) {
|
|
831
834
|
const badges = Badges.createForStep(stepContext, view, componentContext);
|
|
832
|
-
return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput
|
|
835
|
+
return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
|
|
833
836
|
}
|
|
834
837
|
constructor(view, step, parentSequence, hasOutput, badges) {
|
|
835
838
|
this.view = view;
|
|
@@ -915,8 +918,11 @@ class StepComponent {
|
|
|
915
918
|
|
|
916
919
|
class StepComponentViewContextFactory {
|
|
917
920
|
static create(stepContext, componentContext) {
|
|
921
|
+
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
918
922
|
return {
|
|
923
|
+
i18n: componentContext.i18n,
|
|
919
924
|
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
925
|
+
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
920
926
|
createSequenceComponent: (parentElement, sequence) => {
|
|
921
927
|
const sequenceContext = {
|
|
922
928
|
sequence,
|
|
@@ -926,7 +932,12 @@ class StepComponentViewContextFactory {
|
|
|
926
932
|
};
|
|
927
933
|
return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
|
|
928
934
|
},
|
|
929
|
-
|
|
935
|
+
createRegionComponentView(parentElement, componentClassName, contentFactory) {
|
|
936
|
+
return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
|
|
937
|
+
},
|
|
938
|
+
createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
|
|
939
|
+
getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
|
|
940
|
+
setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
|
|
930
941
|
};
|
|
931
942
|
}
|
|
932
943
|
}
|
|
@@ -945,19 +956,22 @@ class StepComponentFactory {
|
|
|
945
956
|
}
|
|
946
957
|
|
|
947
958
|
class ComponentContext {
|
|
948
|
-
static create(
|
|
949
|
-
const validator = new DefinitionValidator(
|
|
950
|
-
const iconProvider = new IconProvider(
|
|
959
|
+
static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, i18n, services) {
|
|
960
|
+
const validator = new DefinitionValidator(configuration.validator, state);
|
|
961
|
+
const iconProvider = new IconProvider(configuration.steps);
|
|
951
962
|
const placeholderController = services.placeholderController.create();
|
|
952
963
|
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
953
|
-
return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, services);
|
|
964
|
+
return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
|
|
954
965
|
}
|
|
955
|
-
constructor(validator, iconProvider, placeholderController, stepComponentFactory, services) {
|
|
966
|
+
constructor(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
|
|
956
967
|
this.validator = validator;
|
|
957
968
|
this.iconProvider = iconProvider;
|
|
958
969
|
this.placeholderController = placeholderController;
|
|
959
970
|
this.stepComponentFactory = stepComponentFactory;
|
|
971
|
+
this.definitionWalker = definitionWalker;
|
|
960
972
|
this.services = services;
|
|
973
|
+
this.preferenceStorage = preferenceStorage;
|
|
974
|
+
this.i18n = i18n;
|
|
961
975
|
}
|
|
962
976
|
}
|
|
963
977
|
|
|
@@ -1082,13 +1096,41 @@ class ValidationErrorBadgeView {
|
|
|
1082
1096
|
}
|
|
1083
1097
|
}
|
|
1084
1098
|
|
|
1099
|
+
class ValidatorFactory {
|
|
1100
|
+
static createForStep(stepContext, view, componentContext) {
|
|
1101
|
+
return () => {
|
|
1102
|
+
if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
if (view.haveCollapsedChildren) {
|
|
1106
|
+
let allChildrenValid = true;
|
|
1107
|
+
componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
|
|
1108
|
+
if (!componentContext.validator.validateStep(step, parentSequence)) {
|
|
1109
|
+
allChildrenValid = false;
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
if (!allChildrenValid) {
|
|
1114
|
+
return false;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return true;
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
static createForRoot(componentContext) {
|
|
1121
|
+
return () => {
|
|
1122
|
+
return componentContext.validator.validateRoot();
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1085
1127
|
class ValidationErrorBadge {
|
|
1086
|
-
static createForStep(parentElement, stepContext, componentContext, configuration) {
|
|
1087
|
-
const validator =
|
|
1128
|
+
static createForStep(parentElement, view, stepContext, componentContext, configuration) {
|
|
1129
|
+
const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
|
|
1088
1130
|
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1089
1131
|
}
|
|
1090
1132
|
static createForRoot(parentElement, componentContext, configuration) {
|
|
1091
|
-
const validator = (
|
|
1133
|
+
const validator = ValidatorFactory.createForRoot(componentContext);
|
|
1092
1134
|
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1093
1135
|
}
|
|
1094
1136
|
constructor(parentElement, validator, configuration) {
|
|
@@ -1130,8 +1172,8 @@ class ValidationErrorBadgeExtension {
|
|
|
1130
1172
|
this.id = 'validationError';
|
|
1131
1173
|
this.createStartValue = () => true;
|
|
1132
1174
|
}
|
|
1133
|
-
createForStep(parentElement, stepContext, componentContext) {
|
|
1134
|
-
return ValidationErrorBadge.createForStep(parentElement, stepContext, componentContext, this.configuration.view);
|
|
1175
|
+
createForStep(parentElement, view, stepContext, componentContext) {
|
|
1176
|
+
return ValidationErrorBadge.createForStep(parentElement, view, stepContext, componentContext, this.configuration.view);
|
|
1135
1177
|
}
|
|
1136
1178
|
createForRoot(parentElement, componentContext) {
|
|
1137
1179
|
return ValidationErrorBadge.createForRoot(parentElement, componentContext, this.configuration.view);
|
|
@@ -1305,53 +1347,6 @@ class OutputView {
|
|
|
1305
1347
|
}
|
|
1306
1348
|
}
|
|
1307
1349
|
|
|
1308
|
-
class RegionView {
|
|
1309
|
-
static create(parent, widths, height) {
|
|
1310
|
-
const totalWidth = widths.reduce((result, width) => result + width, 0);
|
|
1311
|
-
const lines = [
|
|
1312
|
-
drawLine(parent, 0, 0, totalWidth, 0),
|
|
1313
|
-
drawLine(parent, 0, 0, 0, height),
|
|
1314
|
-
drawLine(parent, 0, height, totalWidth, height),
|
|
1315
|
-
drawLine(parent, totalWidth, 0, totalWidth, height)
|
|
1316
|
-
];
|
|
1317
|
-
let offsetX = widths[0];
|
|
1318
|
-
for (let i = 1; i < widths.length; i++) {
|
|
1319
|
-
lines.push(drawLine(parent, offsetX, 0, offsetX, height));
|
|
1320
|
-
offsetX += widths[i];
|
|
1321
|
-
}
|
|
1322
|
-
return new RegionView(lines, totalWidth, height);
|
|
1323
|
-
}
|
|
1324
|
-
constructor(lines, width, height) {
|
|
1325
|
-
this.lines = lines;
|
|
1326
|
-
this.width = width;
|
|
1327
|
-
this.height = height;
|
|
1328
|
-
}
|
|
1329
|
-
getClientPosition() {
|
|
1330
|
-
return getAbsolutePosition(this.lines[0]);
|
|
1331
|
-
}
|
|
1332
|
-
resolveClick(click) {
|
|
1333
|
-
const regionPosition = this.getClientPosition();
|
|
1334
|
-
const d = click.position.subtract(regionPosition);
|
|
1335
|
-
return d.x >= 0 && d.y >= 0 && d.x < this.width * click.scale && d.y < this.height * click.scale;
|
|
1336
|
-
}
|
|
1337
|
-
setIsSelected(isSelected) {
|
|
1338
|
-
this.lines.forEach(region => {
|
|
1339
|
-
Dom.toggleClass(region, isSelected, 'sqd-selected');
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
function drawLine(parent, x1, y1, x2, y2) {
|
|
1344
|
-
const line = Dom.svg('line', {
|
|
1345
|
-
class: 'sqd-region',
|
|
1346
|
-
x1,
|
|
1347
|
-
y1,
|
|
1348
|
-
x2,
|
|
1349
|
-
y2
|
|
1350
|
-
});
|
|
1351
|
-
parent.insertBefore(line, parent.firstChild);
|
|
1352
|
-
return line;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
1350
|
class DefaultSequenceComponentView {
|
|
1356
1351
|
static create(parent, sequenceContext, componentContext) {
|
|
1357
1352
|
const phWidth = componentContext.services.placeholder.gapSize.x;
|
|
@@ -1478,156 +1473,160 @@ class DefaultSequenceComponent {
|
|
|
1478
1473
|
}
|
|
1479
1474
|
}
|
|
1480
1475
|
|
|
1476
|
+
const COMPONENT_CLASS_NAME$2 = 'container';
|
|
1481
1477
|
const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepContext, viewContext) => {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
}
|
|
1524
|
-
};
|
|
1478
|
+
return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$2, (g, regionViewBuilder) => {
|
|
1479
|
+
const step = stepContext.step;
|
|
1480
|
+
const name = viewContext.getStepName();
|
|
1481
|
+
const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary');
|
|
1482
|
+
const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
|
|
1483
|
+
const halfOfWidestElement = labelView.width / 2;
|
|
1484
|
+
const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
|
|
1485
|
+
const offsetRight = Math.max(halfOfWidestElement - (sequenceComponent.view.width - sequenceComponent.view.joinX), 0) + cfg.paddingX;
|
|
1486
|
+
const width = offsetLeft + sequenceComponent.view.width + offsetRight;
|
|
1487
|
+
const height = cfg.paddingTop + cfg.label.height + sequenceComponent.view.height;
|
|
1488
|
+
const joinX = sequenceComponent.view.joinX + offsetLeft;
|
|
1489
|
+
Dom.translate(labelView.g, joinX, 0);
|
|
1490
|
+
Dom.translate(sequenceComponent.view.g, offsetLeft, cfg.paddingTop + cfg.label.height);
|
|
1491
|
+
const iconUrl = viewContext.getStepIconUrl();
|
|
1492
|
+
const inputView = InputView.createRectInput(g, joinX, 0, cfg.inputSize, cfg.inputIconSize, iconUrl);
|
|
1493
|
+
JoinView.createStraightJoin(g, new Vector(joinX, 0), cfg.paddingTop);
|
|
1494
|
+
const regionView = regionViewBuilder(g, [width], height);
|
|
1495
|
+
return {
|
|
1496
|
+
g,
|
|
1497
|
+
width,
|
|
1498
|
+
height,
|
|
1499
|
+
joinX,
|
|
1500
|
+
placeholders: null,
|
|
1501
|
+
sequenceComponents: [sequenceComponent],
|
|
1502
|
+
hasOutput: sequenceComponent.hasOutput,
|
|
1503
|
+
getClientPosition() {
|
|
1504
|
+
return regionView.getClientPosition();
|
|
1505
|
+
},
|
|
1506
|
+
resolveClick(click) {
|
|
1507
|
+
const result = regionView.resolveClick(click);
|
|
1508
|
+
return result === true || (result === null && g.contains(click.element)) ? true : result;
|
|
1509
|
+
},
|
|
1510
|
+
setIsDragging(isDragging) {
|
|
1511
|
+
inputView.setIsHidden(isDragging);
|
|
1512
|
+
},
|
|
1513
|
+
setIsSelected(isSelected) {
|
|
1514
|
+
regionView.setIsSelected(isSelected);
|
|
1515
|
+
},
|
|
1516
|
+
setIsDisabled(isDisabled) {
|
|
1517
|
+
Dom.toggleClass(g, isDisabled, 'sqd-disabled');
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
});
|
|
1525
1521
|
};
|
|
1526
1522
|
|
|
1523
|
+
const COMPONENT_CLASS_NAME$1 = 'switch';
|
|
1527
1524
|
const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, viewContext) => {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1525
|
+
return viewContext.createRegionComponentView(parent, COMPONENT_CLASS_NAME$1, (g, regionViewBuilder) => {
|
|
1526
|
+
const step = stepContext.step;
|
|
1527
|
+
const branchNames = Object.keys(step.branches);
|
|
1528
|
+
const branchComponents = branchNames.map(branchName => {
|
|
1529
|
+
return viewContext.createSequenceComponent(g, step.branches[branchName]);
|
|
1530
|
+
});
|
|
1531
|
+
const branchLabelViews = branchNames.map(branchName => {
|
|
1532
|
+
const labelY = cfg.paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
|
|
1533
|
+
const translatedBranchName = viewContext.i18n(`stepComponent.${step.type}.branchName`, branchName);
|
|
1534
|
+
return LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
|
|
1535
|
+
});
|
|
1536
|
+
const name = viewContext.getStepName();
|
|
1537
|
+
const nameLabelView = LabelView.create(g, cfg.paddingTop, cfg.nameLabel, name, 'primary');
|
|
1538
|
+
let prevOffsetX = 0;
|
|
1539
|
+
const branchSizes = branchComponents.map((component, i) => {
|
|
1540
|
+
const halfOfWidestBranchElement = Math.max(branchLabelViews[i].width, cfg.minContainerWidth) / 2;
|
|
1541
|
+
const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
|
|
1542
|
+
const branchOffsetRight = Math.max(halfOfWidestBranchElement - (component.view.width - component.view.joinX), 0) + cfg.paddingX;
|
|
1543
|
+
const width = component.view.width + branchOffsetLeft + branchOffsetRight;
|
|
1544
|
+
const joinX = component.view.joinX + branchOffsetLeft;
|
|
1545
|
+
const offsetX = prevOffsetX;
|
|
1546
|
+
prevOffsetX += width;
|
|
1547
|
+
return { width, branchOffsetLeft, offsetX, joinX };
|
|
1548
|
+
});
|
|
1549
|
+
const centerBranchIndex = Math.floor(branchNames.length / 2);
|
|
1550
|
+
const centerBranchSize = branchSizes[centerBranchIndex];
|
|
1551
|
+
let joinX = centerBranchSize.offsetX;
|
|
1552
|
+
if (branchNames.length % 2 !== 0) {
|
|
1553
|
+
joinX += centerBranchSize.joinX;
|
|
1554
|
+
}
|
|
1555
|
+
const totalBranchesWidth = branchSizes.reduce((result, s) => result + s.width, 0);
|
|
1556
|
+
const maxBranchesHeight = Math.max(...branchComponents.map(s => s.view.height));
|
|
1557
|
+
const halfOfWidestSwitchElement = nameLabelView.width / 2 + cfg.paddingX;
|
|
1558
|
+
const switchOffsetLeft = Math.max(halfOfWidestSwitchElement - joinX, 0);
|
|
1559
|
+
const switchOffsetRight = Math.max(halfOfWidestSwitchElement - (totalBranchesWidth - joinX), 0);
|
|
1560
|
+
const viewWidth = switchOffsetLeft + totalBranchesWidth + switchOffsetRight;
|
|
1561
|
+
const viewHeight = maxBranchesHeight + cfg.paddingTop + cfg.nameLabel.height + cfg.branchNameLabel.height + cfg.connectionHeight * 2;
|
|
1562
|
+
const shiftedJoinX = switchOffsetLeft + joinX;
|
|
1563
|
+
Dom.translate(nameLabelView.g, shiftedJoinX, 0);
|
|
1564
|
+
const branchOffsetTop = cfg.paddingTop + cfg.nameLabel.height + cfg.branchNameLabel.height + cfg.connectionHeight;
|
|
1565
|
+
branchComponents.forEach((component, i) => {
|
|
1566
|
+
const branchSize = branchSizes[i];
|
|
1567
|
+
const branchOffsetLeft = switchOffsetLeft + branchSize.offsetX + branchSize.branchOffsetLeft;
|
|
1568
|
+
Dom.translate(branchLabelViews[i].g, switchOffsetLeft + branchSize.offsetX + branchSize.joinX, 0);
|
|
1569
|
+
Dom.translate(component.view.g, branchOffsetLeft, branchOffsetTop);
|
|
1570
|
+
if (component.hasOutput && stepContext.isOutputConnected) {
|
|
1571
|
+
const endOffsetTopOfComponent = cfg.paddingTop + cfg.nameLabel.height + cfg.branchNameLabel.height + cfg.connectionHeight + component.view.height;
|
|
1572
|
+
const missingHeight = viewHeight - endOffsetTopOfComponent - cfg.connectionHeight;
|
|
1573
|
+
if (missingHeight > 0) {
|
|
1574
|
+
JoinView.createStraightJoin(g, new Vector(switchOffsetLeft + branchSize.offsetX + branchSize.joinX, endOffsetTopOfComponent), missingHeight);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
});
|
|
1578
|
+
let inputView = null;
|
|
1579
|
+
if (cfg.inputSize > 0) {
|
|
1580
|
+
const iconUrl = viewContext.getStepIconUrl();
|
|
1581
|
+
inputView = InputView.createRectInput(g, shiftedJoinX, 0, cfg.inputSize, cfg.inputIconSize, iconUrl);
|
|
1582
|
+
}
|
|
1583
|
+
JoinView.createStraightJoin(g, new Vector(shiftedJoinX, 0), cfg.paddingTop);
|
|
1584
|
+
JoinView.createJoins(g, new Vector(shiftedJoinX, cfg.paddingTop + cfg.nameLabel.height), branchSizes.map(o => new Vector(switchOffsetLeft + o.offsetX + o.joinX, cfg.paddingTop + cfg.nameLabel.height + cfg.connectionHeight)));
|
|
1585
|
+
if (stepContext.isOutputConnected) {
|
|
1586
|
+
const ongoingSequenceIndexes = branchComponents
|
|
1587
|
+
.map((component, index) => (component.hasOutput ? index : null))
|
|
1588
|
+
.filter(index => index !== null);
|
|
1589
|
+
const ongoingJoinTargets = ongoingSequenceIndexes.map((i) => new Vector(switchOffsetLeft + branchSizes[i].offsetX + branchSizes[i].joinX, cfg.paddingTop + cfg.connectionHeight + cfg.nameLabel.height + cfg.branchNameLabel.height + maxBranchesHeight));
|
|
1590
|
+
if (ongoingJoinTargets.length > 0) {
|
|
1591
|
+
JoinView.createJoins(g, new Vector(shiftedJoinX, viewHeight), ongoingJoinTargets);
|
|
1577
1592
|
}
|
|
1578
1593
|
}
|
|
1594
|
+
const regions = branchSizes.map(s => s.width);
|
|
1595
|
+
regions[0] += switchOffsetLeft;
|
|
1596
|
+
regions[regions.length - 1] += switchOffsetRight;
|
|
1597
|
+
const regionView = regionViewBuilder(g, regions, viewHeight);
|
|
1598
|
+
return {
|
|
1599
|
+
g,
|
|
1600
|
+
width: viewWidth,
|
|
1601
|
+
height: viewHeight,
|
|
1602
|
+
joinX: shiftedJoinX,
|
|
1603
|
+
placeholders: null,
|
|
1604
|
+
sequenceComponents: branchComponents,
|
|
1605
|
+
hasOutput: branchComponents.some(c => c.hasOutput),
|
|
1606
|
+
getClientPosition() {
|
|
1607
|
+
return regionView.getClientPosition();
|
|
1608
|
+
},
|
|
1609
|
+
resolveClick(click) {
|
|
1610
|
+
const result = regionView.resolveClick(click);
|
|
1611
|
+
return result === true || (result === null && g.contains(click.element)) ? true : result;
|
|
1612
|
+
},
|
|
1613
|
+
setIsDragging(isDragging) {
|
|
1614
|
+
inputView === null || inputView === void 0 ? void 0 : inputView.setIsHidden(isDragging);
|
|
1615
|
+
},
|
|
1616
|
+
setIsSelected(isSelected) {
|
|
1617
|
+
regionView.setIsSelected(isSelected);
|
|
1618
|
+
},
|
|
1619
|
+
setIsDisabled(isDisabled) {
|
|
1620
|
+
Dom.toggleClass(g, isDisabled, 'sqd-disabled');
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1579
1623
|
});
|
|
1580
|
-
let inputView = null;
|
|
1581
|
-
if (cfg.inputSize > 0) {
|
|
1582
|
-
const iconUrl = viewContext.getStepIconUrl();
|
|
1583
|
-
inputView = InputView.createRectInput(g, shiftedJoinX, 0, cfg.inputSize, cfg.inputIconSize, iconUrl);
|
|
1584
|
-
}
|
|
1585
|
-
JoinView.createStraightJoin(g, new Vector(shiftedJoinX, 0), cfg.paddingTop);
|
|
1586
|
-
JoinView.createJoins(g, new Vector(shiftedJoinX, cfg.paddingTop + cfg.nameLabel.height), branchSizes.map(o => new Vector(switchOffsetLeft + o.offsetX + o.joinX, cfg.paddingTop + cfg.nameLabel.height + cfg.connectionHeight)));
|
|
1587
|
-
if (stepContext.isOutputConnected) {
|
|
1588
|
-
const ongoingSequenceIndexes = branchComponents
|
|
1589
|
-
.map((component, index) => (component.hasOutput ? index : null))
|
|
1590
|
-
.filter(index => index !== null);
|
|
1591
|
-
const ongoingJoinTargets = ongoingSequenceIndexes.map((i) => new Vector(switchOffsetLeft + branchSizes[i].offsetX + branchSizes[i].joinX, cfg.paddingTop + cfg.connectionHeight + cfg.nameLabel.height + cfg.branchNameLabel.height + maxBranchesHeight));
|
|
1592
|
-
if (ongoingJoinTargets.length > 0) {
|
|
1593
|
-
JoinView.createJoins(g, new Vector(shiftedJoinX, viewHeight), ongoingJoinTargets);
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
const regions = branchSizes.map(s => s.width);
|
|
1597
|
-
regions[0] += switchOffsetLeft;
|
|
1598
|
-
regions[regions.length - 1] += switchOffsetRight;
|
|
1599
|
-
const regionView = RegionView.create(g, regions, viewHeight);
|
|
1600
|
-
return {
|
|
1601
|
-
g,
|
|
1602
|
-
width: viewWidth,
|
|
1603
|
-
height: viewHeight,
|
|
1604
|
-
joinX: shiftedJoinX,
|
|
1605
|
-
placeholders: null,
|
|
1606
|
-
sequenceComponents: branchComponents,
|
|
1607
|
-
getClientPosition() {
|
|
1608
|
-
return regionView.getClientPosition();
|
|
1609
|
-
},
|
|
1610
|
-
resolveClick(click) {
|
|
1611
|
-
return regionView.resolveClick(click) || g.contains(click.element) ? true : null;
|
|
1612
|
-
},
|
|
1613
|
-
setIsDragging(isDragging) {
|
|
1614
|
-
inputView === null || inputView === void 0 ? void 0 : inputView.setIsHidden(isDragging);
|
|
1615
|
-
},
|
|
1616
|
-
setIsSelected(isSelected) {
|
|
1617
|
-
regionView.setIsSelected(isSelected);
|
|
1618
|
-
},
|
|
1619
|
-
setIsDisabled(isDisabled) {
|
|
1620
|
-
Dom.toggleClass(g, isDisabled, 'sqd-disabled');
|
|
1621
|
-
},
|
|
1622
|
-
hasOutput() {
|
|
1623
|
-
return branchComponents.some(c => c.hasOutput);
|
|
1624
|
-
}
|
|
1625
|
-
};
|
|
1626
1624
|
};
|
|
1627
1625
|
|
|
1626
|
+
const COMPONENT_CLASS_NAME = 'task';
|
|
1628
1627
|
const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElement, stepContext, viewContext) => {
|
|
1629
1628
|
const { step } = stepContext;
|
|
1630
|
-
const g = ComponentDom.stepG(
|
|
1629
|
+
const g = ComponentDom.stepG(COMPONENT_CLASS_NAME, step.type, step.id);
|
|
1631
1630
|
parentElement.appendChild(g);
|
|
1632
1631
|
const boxHeight = cfg.paddingY * 2 + cfg.iconSize;
|
|
1633
1632
|
const text = Dom.svg('text', {
|
|
@@ -1635,7 +1634,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1635
1634
|
y: boxHeight / 2,
|
|
1636
1635
|
class: 'sqd-step-task-text'
|
|
1637
1636
|
});
|
|
1638
|
-
text.textContent =
|
|
1637
|
+
text.textContent = viewContext.getStepName();
|
|
1639
1638
|
g.appendChild(text);
|
|
1640
1639
|
const textWidth = Math.max(text.getBBox().width, cfg.minTextWidth);
|
|
1641
1640
|
const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + textWidth;
|
|
@@ -1677,9 +1676,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1677
1676
|
joinX: boxWidth / 2,
|
|
1678
1677
|
sequenceComponents: null,
|
|
1679
1678
|
placeholders: null,
|
|
1680
|
-
hasOutput
|
|
1681
|
-
return !!outputView;
|
|
1682
|
-
},
|
|
1679
|
+
hasOutput: !!outputView,
|
|
1683
1680
|
getClientPosition() {
|
|
1684
1681
|
return getAbsolutePosition(rect);
|
|
1685
1682
|
},
|
|
@@ -1968,6 +1965,64 @@ class RectPlaceholder {
|
|
|
1968
1965
|
}
|
|
1969
1966
|
}
|
|
1970
1967
|
|
|
1968
|
+
class DefaultRegionView {
|
|
1969
|
+
static create(parent, widths, height) {
|
|
1970
|
+
const totalWidth = widths.reduce((result, width) => result + width, 0);
|
|
1971
|
+
const lines = [
|
|
1972
|
+
drawLine(parent, 0, 0, totalWidth, 0),
|
|
1973
|
+
drawLine(parent, 0, 0, 0, height),
|
|
1974
|
+
drawLine(parent, 0, height, totalWidth, height),
|
|
1975
|
+
drawLine(parent, totalWidth, 0, totalWidth, height)
|
|
1976
|
+
];
|
|
1977
|
+
let offsetX = widths[0];
|
|
1978
|
+
for (let i = 1; i < widths.length; i++) {
|
|
1979
|
+
lines.push(drawLine(parent, offsetX, 0, offsetX, height));
|
|
1980
|
+
offsetX += widths[i];
|
|
1981
|
+
}
|
|
1982
|
+
return new DefaultRegionView(lines, totalWidth, height);
|
|
1983
|
+
}
|
|
1984
|
+
constructor(lines, width, height) {
|
|
1985
|
+
this.lines = lines;
|
|
1986
|
+
this.width = width;
|
|
1987
|
+
this.height = height;
|
|
1988
|
+
}
|
|
1989
|
+
getClientPosition() {
|
|
1990
|
+
return getAbsolutePosition(this.lines[0]);
|
|
1991
|
+
}
|
|
1992
|
+
resolveClick(click) {
|
|
1993
|
+
const regionPosition = this.getClientPosition();
|
|
1994
|
+
const d = click.position.subtract(regionPosition);
|
|
1995
|
+
if (d.x >= 0 && d.y >= 0 && d.x < this.width * click.scale && d.y < this.height * click.scale) {
|
|
1996
|
+
return true;
|
|
1997
|
+
}
|
|
1998
|
+
return null;
|
|
1999
|
+
}
|
|
2000
|
+
setIsSelected(isSelected) {
|
|
2001
|
+
this.lines.forEach(region => {
|
|
2002
|
+
Dom.toggleClass(region, isSelected, 'sqd-selected');
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
function drawLine(parent, x1, y1, x2, y2) {
|
|
2007
|
+
const line = Dom.svg('line', {
|
|
2008
|
+
class: 'sqd-region',
|
|
2009
|
+
x1,
|
|
2010
|
+
y1,
|
|
2011
|
+
x2,
|
|
2012
|
+
y2
|
|
2013
|
+
});
|
|
2014
|
+
parent.insertBefore(line, parent.firstChild);
|
|
2015
|
+
return line;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
class DefaultRegionComponentViewExtension {
|
|
2019
|
+
create(parentElement, componentClassName, stepContext, _, contentFactory) {
|
|
2020
|
+
const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
|
|
2021
|
+
parentElement.appendChild(g);
|
|
2022
|
+
return contentFactory(g, DefaultRegionView.create);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
|
|
1971
2026
|
function readMousePosition(e) {
|
|
1972
2027
|
return new Vector(e.pageX, e.pageY);
|
|
1973
2028
|
}
|
|
@@ -2469,9 +2524,22 @@ class WorkspaceControllerWrapper {
|
|
|
2469
2524
|
}
|
|
2470
2525
|
}
|
|
2471
2526
|
|
|
2527
|
+
class MemoryPreferenceStorage {
|
|
2528
|
+
constructor() {
|
|
2529
|
+
this.map = {};
|
|
2530
|
+
}
|
|
2531
|
+
setItem(key, value) {
|
|
2532
|
+
this.map[key] = value;
|
|
2533
|
+
}
|
|
2534
|
+
getItem(key) {
|
|
2535
|
+
var _a;
|
|
2536
|
+
return (_a = this.map[key]) !== null && _a !== void 0 ? _a : null;
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2472
2540
|
class DesignerContext {
|
|
2473
2541
|
static create(parent, startDefinition, configuration, services) {
|
|
2474
|
-
var _a, _b, _c;
|
|
2542
|
+
var _a, _b, _c, _d, _e;
|
|
2475
2543
|
const definition = ObjectCloner.deepClone(startDefinition);
|
|
2476
2544
|
const layoutController = new LayoutController(parent);
|
|
2477
2545
|
const isReadonly = !!configuration.isReadonly;
|
|
@@ -2483,22 +2551,25 @@ class DesignerContext {
|
|
|
2483
2551
|
const behaviorController = new BehaviorController();
|
|
2484
2552
|
const stepExtensionResolver = StepExtensionResolver.create(services);
|
|
2485
2553
|
const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new sequentialWorkflowModel.DefinitionWalker();
|
|
2554
|
+
const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
|
|
2486
2555
|
const stateModifier = StateModifier.create(definitionWalker, state, configuration);
|
|
2487
2556
|
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
2488
2557
|
let historyController = undefined;
|
|
2489
2558
|
if (configuration.undoStackSize) {
|
|
2490
2559
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
2491
2560
|
}
|
|
2492
|
-
const
|
|
2493
|
-
|
|
2561
|
+
const preferenceStorage = (_e = configuration.preferenceStorage) !== null && _e !== void 0 ? _e : new MemoryPreferenceStorage();
|
|
2562
|
+
const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, i18n, services);
|
|
2563
|
+
return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController);
|
|
2494
2564
|
}
|
|
2495
|
-
constructor(theme, state, configuration, services, componentContext, definitionWalker, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController) {
|
|
2565
|
+
constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController) {
|
|
2496
2566
|
this.theme = theme;
|
|
2497
2567
|
this.state = state;
|
|
2498
2568
|
this.configuration = configuration;
|
|
2499
2569
|
this.services = services;
|
|
2500
2570
|
this.componentContext = componentContext;
|
|
2501
2571
|
this.definitionWalker = definitionWalker;
|
|
2572
|
+
this.i18n = i18n;
|
|
2502
2573
|
this.stateModifier = stateModifier;
|
|
2503
2574
|
this.layoutController = layoutController;
|
|
2504
2575
|
this.workspaceController = workspaceController;
|
|
@@ -2911,8 +2982,9 @@ class ContextMenuController {
|
|
|
2911
2982
|
}
|
|
2912
2983
|
|
|
2913
2984
|
class ContextMenuItemsBuilder {
|
|
2914
|
-
constructor(viewportApi, stateModifier, state, customMenuItemsProvider) {
|
|
2985
|
+
constructor(viewportApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
2915
2986
|
this.viewportApi = viewportApi;
|
|
2987
|
+
this.i18n = i18n;
|
|
2916
2988
|
this.stateModifier = stateModifier;
|
|
2917
2989
|
this.state = state;
|
|
2918
2990
|
this.customMenuItemsProvider = customMenuItemsProvider;
|
|
@@ -2923,15 +2995,16 @@ class ContextMenuItemsBuilder {
|
|
|
2923
2995
|
const ssc = commandOrNull;
|
|
2924
2996
|
const step = ssc.component.step;
|
|
2925
2997
|
const parentSequence = ssc.component.parentSequence;
|
|
2998
|
+
const name = this.i18n(`step.${step.type}.name`, step.name);
|
|
2926
2999
|
items.push({
|
|
2927
|
-
label:
|
|
3000
|
+
label: name,
|
|
2928
3001
|
order: 0
|
|
2929
3002
|
});
|
|
2930
3003
|
this.tryAppendCustomItems(items, step, parentSequence);
|
|
2931
3004
|
if (this.stateModifier.isSelectable(step, parentSequence)) {
|
|
2932
3005
|
if (this.state.selectedStepId === step.id) {
|
|
2933
3006
|
items.push({
|
|
2934
|
-
label:
|
|
3007
|
+
label: this.i18n('contextMenu.unselect', 'Unselect'),
|
|
2935
3008
|
order: 10,
|
|
2936
3009
|
callback: () => {
|
|
2937
3010
|
this.state.setSelectedStepId(null);
|
|
@@ -2940,7 +3013,7 @@ class ContextMenuItemsBuilder {
|
|
|
2940
3013
|
}
|
|
2941
3014
|
else {
|
|
2942
3015
|
items.push({
|
|
2943
|
-
label: 'Select',
|
|
3016
|
+
label: this.i18n('contextMenu.select', 'Select'),
|
|
2944
3017
|
order: 20,
|
|
2945
3018
|
callback: () => {
|
|
2946
3019
|
this.stateModifier.trySelectStepById(step.id);
|
|
@@ -2951,7 +3024,7 @@ class ContextMenuItemsBuilder {
|
|
|
2951
3024
|
if (!this.state.isReadonly) {
|
|
2952
3025
|
if (this.stateModifier.isDeletable(step.id)) {
|
|
2953
3026
|
items.push({
|
|
2954
|
-
label: 'Delete',
|
|
3027
|
+
label: this.i18n('contextMenu.delete', 'Delete'),
|
|
2955
3028
|
order: 30,
|
|
2956
3029
|
callback: () => {
|
|
2957
3030
|
this.stateModifier.tryDelete(step.id);
|
|
@@ -2960,7 +3033,7 @@ class ContextMenuItemsBuilder {
|
|
|
2960
3033
|
}
|
|
2961
3034
|
if (this.stateModifier.isDuplicable(step, parentSequence)) {
|
|
2962
3035
|
items.push({
|
|
2963
|
-
label: 'Duplicate',
|
|
3036
|
+
label: this.i18n('contextMenu.duplicate', 'Duplicate'),
|
|
2964
3037
|
order: 40,
|
|
2965
3038
|
callback: () => {
|
|
2966
3039
|
this.stateModifier.tryDuplicate(step, parentSequence);
|
|
@@ -2973,7 +3046,7 @@ class ContextMenuItemsBuilder {
|
|
|
2973
3046
|
this.tryAppendCustomItems(items, null, this.state.definition.sequence);
|
|
2974
3047
|
}
|
|
2975
3048
|
items.push({
|
|
2976
|
-
label: 'Reset view',
|
|
3049
|
+
label: this.i18n('contextMenu.resetView', 'Reset view'),
|
|
2977
3050
|
order: 50,
|
|
2978
3051
|
callback: () => {
|
|
2979
3052
|
this.viewportApi.resetViewport();
|
|
@@ -2998,7 +3071,7 @@ class Workspace {
|
|
|
2998
3071
|
const view = WorkspaceView.create(parent, designerContext.componentContext);
|
|
2999
3072
|
const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
|
|
3000
3073
|
const wheelController = designerContext.services.wheelController.create(api.workspace);
|
|
3001
|
-
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3074
|
+
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3002
3075
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3003
3076
|
: undefined);
|
|
3004
3077
|
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
@@ -3245,28 +3318,28 @@ class DefaultDraggedComponentExtension {
|
|
|
3245
3318
|
}
|
|
3246
3319
|
|
|
3247
3320
|
class ControlBarView {
|
|
3248
|
-
static create(parent, isUndoRedoSupported) {
|
|
3321
|
+
static create(parent, isUndoRedoSupported, i18n) {
|
|
3249
3322
|
const root = Dom.element('div', {
|
|
3250
3323
|
class: 'sqd-control-bar'
|
|
3251
3324
|
});
|
|
3252
|
-
const resetButton = createButton(Icons.center, 'Reset view');
|
|
3325
|
+
const resetButton = createButton(Icons.center, i18n('controlBar.resetView', 'Reset view'));
|
|
3253
3326
|
root.appendChild(resetButton);
|
|
3254
|
-
const zoomInButton = createButton(Icons.zoomIn, 'Zoom in');
|
|
3327
|
+
const zoomInButton = createButton(Icons.zoomIn, i18n('controlBar.zoomIn', 'Zoom in'));
|
|
3255
3328
|
root.appendChild(zoomInButton);
|
|
3256
|
-
const zoomOutButton = createButton(Icons.zoomOut, 'Zoom out');
|
|
3329
|
+
const zoomOutButton = createButton(Icons.zoomOut, i18n('controlBar.zoomOut', 'Zoom out'));
|
|
3257
3330
|
root.appendChild(zoomOutButton);
|
|
3258
3331
|
let undoButton = null;
|
|
3259
3332
|
let redoButton = null;
|
|
3260
3333
|
if (isUndoRedoSupported) {
|
|
3261
|
-
undoButton = createButton(Icons.undo, 'Undo');
|
|
3334
|
+
undoButton = createButton(Icons.undo, i18n('controlBar.undo', 'Undo'));
|
|
3262
3335
|
root.appendChild(undoButton);
|
|
3263
|
-
redoButton = createButton(Icons.redo, 'Redo');
|
|
3336
|
+
redoButton = createButton(Icons.redo, i18n('controlBar.redo', 'Redo'));
|
|
3264
3337
|
root.appendChild(redoButton);
|
|
3265
3338
|
}
|
|
3266
|
-
const disableDragButton = createButton(Icons.move, 'Turn on/off drag and drop');
|
|
3339
|
+
const disableDragButton = createButton(Icons.move, i18n('controlBar.turnOnOffDragAndDrop', 'Turn on/off drag and drop'));
|
|
3267
3340
|
disableDragButton.classList.add('sqd-disabled');
|
|
3268
3341
|
root.appendChild(disableDragButton);
|
|
3269
|
-
const deleteButton = createButton(Icons.delete, 'Delete selected step');
|
|
3342
|
+
const deleteButton = createButton(Icons.delete, i18n('controlBar.deleteSelectedStep', 'Delete selected step'));
|
|
3270
3343
|
deleteButton.classList.add('sqd-delete');
|
|
3271
3344
|
deleteButton.classList.add('sqd-hidden');
|
|
3272
3345
|
root.appendChild(deleteButton);
|
|
@@ -3347,7 +3420,7 @@ function createButton(d, title) {
|
|
|
3347
3420
|
class ControlBar {
|
|
3348
3421
|
static create(parent, api) {
|
|
3349
3422
|
const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
|
|
3350
|
-
const view = ControlBarView.create(parent, isUndoRedoSupported);
|
|
3423
|
+
const view = ControlBarView.create(parent, isUndoRedoSupported, api.i18n);
|
|
3351
3424
|
const bar = new ControlBar(view, api.controlBar, isUndoRedoSupported);
|
|
3352
3425
|
view.bindResetButtonClick(() => bar.onResetButtonClicked());
|
|
3353
3426
|
view.bindZoomInButtonClick(() => bar.onZoomInButtonClicked());
|
|
@@ -3477,19 +3550,16 @@ class KeyboardDaemonExtension {
|
|
|
3477
3550
|
}
|
|
3478
3551
|
|
|
3479
3552
|
class SmartEditorView {
|
|
3480
|
-
static create(parent, api, configuration) {
|
|
3553
|
+
static create(parent, api, i18n, configuration) {
|
|
3481
3554
|
const root = Dom.element('div', {
|
|
3482
3555
|
class: 'sqd-smart-editor'
|
|
3483
3556
|
});
|
|
3484
3557
|
const toggle = Dom.element('div', {
|
|
3485
3558
|
class: 'sqd-smart-editor-toggle',
|
|
3486
|
-
title: 'Toggle editor'
|
|
3559
|
+
title: i18n('smartEditor.toggle', 'Toggle editor')
|
|
3487
3560
|
});
|
|
3488
3561
|
parent.appendChild(toggle);
|
|
3489
3562
|
parent.appendChild(root);
|
|
3490
|
-
if (configuration.globalEditorProvider) {
|
|
3491
|
-
throw new Error('globalEditorProvider is renamed to rootEditorProvider');
|
|
3492
|
-
}
|
|
3493
3563
|
const editor = Editor.create(root, api, 'sqd-editor sqd-step-editor', configuration.stepEditorProvider, 'sqd-editor sqd-root-editor', configuration.rootEditorProvider, null);
|
|
3494
3564
|
return new SmartEditorView(root, toggle, editor);
|
|
3495
3565
|
}
|
|
@@ -3520,7 +3590,7 @@ class SmartEditorView {
|
|
|
3520
3590
|
|
|
3521
3591
|
class SmartEditor {
|
|
3522
3592
|
static create(parent, api, configuration) {
|
|
3523
|
-
const view = SmartEditorView.create(parent, api.editor, configuration);
|
|
3593
|
+
const view = SmartEditorView.create(parent, api.editor, api.i18n, configuration);
|
|
3524
3594
|
const editor = new SmartEditor(view, api.editor, api.workspace);
|
|
3525
3595
|
editor.updateVisibility();
|
|
3526
3596
|
view.bindToggleClick(() => editor.onToggleClicked());
|
|
@@ -3763,7 +3833,7 @@ class ToolboxItem {
|
|
|
3763
3833
|
}
|
|
3764
3834
|
|
|
3765
3835
|
class ToolboxView {
|
|
3766
|
-
static create(parent, api) {
|
|
3836
|
+
static create(parent, api, i18n) {
|
|
3767
3837
|
const root = Dom.element('div', {
|
|
3768
3838
|
class: 'sqd-toolbox'
|
|
3769
3839
|
});
|
|
@@ -3773,14 +3843,14 @@ class ToolboxView {
|
|
|
3773
3843
|
const headerTitle = Dom.element('div', {
|
|
3774
3844
|
class: 'sqd-toolbox-header-title'
|
|
3775
3845
|
});
|
|
3776
|
-
headerTitle.innerText = 'Toolbox';
|
|
3846
|
+
headerTitle.innerText = i18n('toolbox.title', 'Toolbox');
|
|
3777
3847
|
const body = Dom.element('div', {
|
|
3778
3848
|
class: 'sqd-toolbox-body'
|
|
3779
3849
|
});
|
|
3780
3850
|
const filterInput = Dom.element('input', {
|
|
3781
3851
|
class: 'sqd-toolbox-filter',
|
|
3782
3852
|
type: 'text',
|
|
3783
|
-
placeholder: 'Search...'
|
|
3853
|
+
placeholder: i18n('toolbox.search', 'Search...')
|
|
3784
3854
|
});
|
|
3785
3855
|
root.appendChild(header);
|
|
3786
3856
|
root.appendChild(body);
|
|
@@ -3840,9 +3910,9 @@ class ToolboxView {
|
|
|
3840
3910
|
}
|
|
3841
3911
|
|
|
3842
3912
|
class Toolbox {
|
|
3843
|
-
static create(root, api) {
|
|
3913
|
+
static create(root, api, i18n) {
|
|
3844
3914
|
const allGroups = api.getAllGroups();
|
|
3845
|
-
const view = ToolboxView.create(root, api);
|
|
3915
|
+
const view = ToolboxView.create(root, api, i18n);
|
|
3846
3916
|
const toolbox = new Toolbox(view, api, allGroups);
|
|
3847
3917
|
toolbox.render();
|
|
3848
3918
|
toolbox.onIsCollapsedChanged();
|
|
@@ -3877,7 +3947,7 @@ class Toolbox {
|
|
|
3877
3947
|
|
|
3878
3948
|
class ToolboxExtension {
|
|
3879
3949
|
create(root, api) {
|
|
3880
|
-
return Toolbox.create(root, api.toolbox);
|
|
3950
|
+
return Toolbox.create(root, api.toolbox, api.i18n);
|
|
3881
3951
|
}
|
|
3882
3952
|
}
|
|
3883
3953
|
|
|
@@ -3915,7 +3985,7 @@ class DefaultPlaceholderControllerExtension {
|
|
|
3915
3985
|
}
|
|
3916
3986
|
|
|
3917
3987
|
const defaultConfiguration$3 = {
|
|
3918
|
-
gapWidth:
|
|
3988
|
+
gapWidth: 88,
|
|
3919
3989
|
gapHeight: 24,
|
|
3920
3990
|
radius: 6,
|
|
3921
3991
|
iconSize: 16
|
|
@@ -4184,6 +4254,9 @@ function merge(services, extensions) {
|
|
|
4184
4254
|
if (ext.placeholder) {
|
|
4185
4255
|
services.placeholder = ext.placeholder;
|
|
4186
4256
|
}
|
|
4257
|
+
if (ext.regionComponentView) {
|
|
4258
|
+
services.regionComponentView = ext.regionComponentView;
|
|
4259
|
+
}
|
|
4187
4260
|
if (ext.viewportController) {
|
|
4188
4261
|
services.viewportController = ext.viewportController;
|
|
4189
4262
|
}
|
|
@@ -4244,6 +4317,9 @@ function setDefaults(services, configuration) {
|
|
|
4244
4317
|
if (!services.placeholder) {
|
|
4245
4318
|
services.placeholder = RectPlaceholderExtension.create();
|
|
4246
4319
|
}
|
|
4320
|
+
if (!services.regionComponentView) {
|
|
4321
|
+
services.regionComponentView = new DefaultRegionComponentViewExtension();
|
|
4322
|
+
}
|
|
4247
4323
|
if (!services.viewportController) {
|
|
4248
4324
|
services.viewportController = new DefaultViewportControllerExtension();
|
|
4249
4325
|
}
|
|
@@ -4529,6 +4605,8 @@ exports.ComponentContext = ComponentContext;
|
|
|
4529
4605
|
exports.ComponentDom = ComponentDom;
|
|
4530
4606
|
exports.ControlBarApi = ControlBarApi;
|
|
4531
4607
|
exports.CustomActionController = CustomActionController;
|
|
4608
|
+
exports.DefaultRegionComponentViewExtension = DefaultRegionComponentViewExtension;
|
|
4609
|
+
exports.DefaultRegionView = DefaultRegionView;
|
|
4532
4610
|
exports.DefaultSequenceComponent = DefaultSequenceComponent;
|
|
4533
4611
|
exports.DefaultSequenceComponentView = DefaultSequenceComponentView;
|
|
4534
4612
|
exports.DefaultViewportController = DefaultViewportController;
|
|
@@ -4551,7 +4629,6 @@ exports.PathBarApi = PathBarApi;
|
|
|
4551
4629
|
exports.QuantifiedScaleViewportCalculator = QuantifiedScaleViewportCalculator;
|
|
4552
4630
|
exports.RectPlaceholder = RectPlaceholder;
|
|
4553
4631
|
exports.RectPlaceholderView = RectPlaceholderView;
|
|
4554
|
-
exports.RegionView = RegionView;
|
|
4555
4632
|
exports.ServicesResolver = ServicesResolver;
|
|
4556
4633
|
exports.SimpleEvent = SimpleEvent;
|
|
4557
4634
|
exports.StepComponent = StepComponent;
|