sequential-workflow-designer 0.37.4 → 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 +4 -4
- package/dist/index.umd.js +33 -25
- package/lib/cjs/index.cjs +33 -25
- package/lib/esm/index.js +33 -25
- package/lib/index.d.ts +10 -7
- package/package.json +1 -1
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.
|
|
111
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
112
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
113
|
-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
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)
|
|
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);
|
|
@@ -138,10 +139,6 @@
|
|
|
138
139
|
listener(value);
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
|
-
/**
|
|
142
|
-
* @deprecated Use `emit` method instead.
|
|
143
|
-
*/
|
|
144
|
-
this.forward = this.emit;
|
|
145
142
|
}
|
|
146
143
|
subscribe(listener) {
|
|
147
144
|
this.listeners.push(listener);
|
|
@@ -1344,7 +1341,7 @@
|
|
|
1344
1341
|
}
|
|
1345
1342
|
|
|
1346
1343
|
class LabelView {
|
|
1347
|
-
static create(parent, y, cfg, text, theme) {
|
|
1344
|
+
static create(parent, y, cfg, text, theme, textWidthMeasurer) {
|
|
1348
1345
|
const g = Dom.svg('g', {
|
|
1349
1346
|
class: `sqd-label sqd-label-${theme}`
|
|
1350
1347
|
});
|
|
@@ -1355,7 +1352,8 @@
|
|
|
1355
1352
|
});
|
|
1356
1353
|
nameText.textContent = text;
|
|
1357
1354
|
g.appendChild(nameText);
|
|
1358
|
-
const
|
|
1355
|
+
const nameWidth = textWidthMeasurer(nameText);
|
|
1356
|
+
const width = Math.max(nameWidth + cfg.paddingX * 2, cfg.minWidth);
|
|
1359
1357
|
const nameRect = Dom.svg('rect', {
|
|
1360
1358
|
class: 'sqd-label-rect',
|
|
1361
1359
|
width: width,
|
|
@@ -1411,7 +1409,9 @@
|
|
|
1411
1409
|
const { sequence } = sequenceContext;
|
|
1412
1410
|
const g = Dom.svg('g');
|
|
1413
1411
|
parent.appendChild(g);
|
|
1414
|
-
const components =
|
|
1412
|
+
const components = new Array(sequence.length);
|
|
1413
|
+
let restWidth = 0;
|
|
1414
|
+
let joinX = 0;
|
|
1415
1415
|
for (let index = 0; index < sequence.length; index++) {
|
|
1416
1416
|
const stepContext = {
|
|
1417
1417
|
parentSequence: sequenceContext.sequence,
|
|
@@ -1422,13 +1422,13 @@
|
|
|
1422
1422
|
isOutputConnected: index === sequence.length - 1 ? sequenceContext.isOutputConnected : true,
|
|
1423
1423
|
isPreview: sequenceContext.isPreview
|
|
1424
1424
|
};
|
|
1425
|
-
|
|
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);
|
|
1426
1429
|
}
|
|
1427
|
-
let joinX;
|
|
1428
1430
|
let totalWidth;
|
|
1429
|
-
if (
|
|
1430
|
-
const restWidth = Math.max(...components.map(c => c.view.width - c.view.joinX));
|
|
1431
|
-
joinX = Math.max(...components.map(c => c.view.joinX));
|
|
1431
|
+
if (sequence.length > 0) {
|
|
1432
1432
|
totalWidth = joinX + restWidth;
|
|
1433
1433
|
}
|
|
1434
1434
|
else {
|
|
@@ -1660,7 +1660,7 @@
|
|
|
1660
1660
|
return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
|
|
1661
1661
|
const step = stepContext.step;
|
|
1662
1662
|
const name = viewContext.getStepName();
|
|
1663
|
-
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);
|
|
1664
1664
|
const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
|
|
1665
1665
|
const halfOfWidestElement = labelView.width / 2;
|
|
1666
1666
|
const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
|
|
@@ -1906,7 +1906,7 @@
|
|
|
1906
1906
|
const step = stepContext.step;
|
|
1907
1907
|
const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
|
|
1908
1908
|
const name = viewContext.getStepName();
|
|
1909
|
-
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
|
|
1909
|
+
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary', viewContext.textWidthMeasurer);
|
|
1910
1910
|
const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
|
|
1911
1911
|
if (branchNames.length === 0) {
|
|
1912
1912
|
const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
|
|
@@ -1927,7 +1927,7 @@
|
|
|
1927
1927
|
const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
|
|
1928
1928
|
const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
|
|
1929
1929
|
const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
|
|
1930
|
-
const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
|
|
1930
|
+
const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary', viewContext.textWidthMeasurer);
|
|
1931
1931
|
const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
|
|
1932
1932
|
const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
|
|
1933
1933
|
const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
|
|
@@ -2003,8 +2003,9 @@
|
|
|
2003
2003
|
});
|
|
2004
2004
|
text.textContent = viewContext.getStepName();
|
|
2005
2005
|
g.appendChild(text);
|
|
2006
|
-
const textWidth =
|
|
2007
|
-
const
|
|
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;
|
|
2008
2009
|
const rect = Dom.svg('rect', {
|
|
2009
2010
|
x: 0.5,
|
|
2010
2011
|
y: 0.5,
|
|
@@ -2014,7 +2015,6 @@
|
|
|
2014
2015
|
rx: cfg.radius,
|
|
2015
2016
|
ry: cfg.radius
|
|
2016
2017
|
});
|
|
2017
|
-
g.insertBefore(rect, text);
|
|
2018
2018
|
const iconUrl = viewContext.getStepIconUrl();
|
|
2019
2019
|
const icon = iconUrl
|
|
2020
2020
|
? Dom.svg('image', {
|
|
@@ -2031,6 +2031,7 @@
|
|
|
2031
2031
|
width: cfg.iconSize,
|
|
2032
2032
|
height: cfg.iconSize
|
|
2033
2033
|
});
|
|
2034
|
+
g.insertBefore(rect, text);
|
|
2034
2035
|
g.appendChild(icon);
|
|
2035
2036
|
const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
|
|
2036
2037
|
const isOutputViewHidden = isInterrupted;
|
|
@@ -2717,6 +2718,7 @@
|
|
|
2717
2718
|
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
2718
2719
|
return {
|
|
2719
2720
|
i18n: componentContext.i18n,
|
|
2721
|
+
textWidthMeasurer: componentContext.textWidthMeasurer,
|
|
2720
2722
|
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
2721
2723
|
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
2722
2724
|
createStepComponent: (parentElement, parentSequence, step, position) => {
|
|
@@ -2771,13 +2773,13 @@
|
|
|
2771
2773
|
}
|
|
2772
2774
|
|
|
2773
2775
|
class ComponentContext {
|
|
2774
|
-
static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
|
|
2776
|
+
static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services) {
|
|
2775
2777
|
const validator = new DefinitionValidator(configuration.validator, state);
|
|
2776
2778
|
const iconProvider = new IconProvider(configuration.steps);
|
|
2777
2779
|
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
2778
|
-
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);
|
|
2779
2781
|
}
|
|
2780
|
-
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state) {
|
|
2782
|
+
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state) {
|
|
2781
2783
|
this.shadowRoot = shadowRoot;
|
|
2782
2784
|
this.validator = validator;
|
|
2783
2785
|
this.iconProvider = iconProvider;
|
|
@@ -2787,6 +2789,7 @@
|
|
|
2787
2789
|
this.services = services;
|
|
2788
2790
|
this.preferenceStorage = preferenceStorage;
|
|
2789
2791
|
this.i18n = i18n;
|
|
2792
|
+
this.textWidthMeasurer = textWidthMeasurer;
|
|
2790
2793
|
this.state = state;
|
|
2791
2794
|
}
|
|
2792
2795
|
getViewportScale() {
|
|
@@ -3507,9 +3510,13 @@
|
|
|
3507
3510
|
}
|
|
3508
3511
|
}
|
|
3509
3512
|
|
|
3513
|
+
function measureTextWidth(text) {
|
|
3514
|
+
return text.getBBox().width;
|
|
3515
|
+
}
|
|
3516
|
+
|
|
3510
3517
|
class DesignerContext {
|
|
3511
3518
|
static create(placeholder, startDefinition, configuration, services) {
|
|
3512
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3519
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3513
3520
|
const definition = ObjectCloner.deepClone(startDefinition);
|
|
3514
3521
|
const layoutController = new LayoutController(placeholder);
|
|
3515
3522
|
const isReadonly = Boolean(configuration.isReadonly);
|
|
@@ -3525,13 +3532,14 @@
|
|
|
3525
3532
|
const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new DefinitionWalker();
|
|
3526
3533
|
const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
|
|
3527
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;
|
|
3528
3536
|
const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
|
|
3529
3537
|
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
3530
3538
|
let historyController = undefined;
|
|
3531
3539
|
if (configuration.undoStackSize) {
|
|
3532
3540
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
3533
3541
|
}
|
|
3534
|
-
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);
|
|
3535
3543
|
return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
|
|
3536
3544
|
}
|
|
3537
3545
|
constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
|
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)
|
|
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);
|
|
@@ -136,10 +137,6 @@ class SimpleEvent {
|
|
|
136
137
|
listener(value);
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
|
-
/**
|
|
140
|
-
* @deprecated Use `emit` method instead.
|
|
141
|
-
*/
|
|
142
|
-
this.forward = this.emit;
|
|
143
140
|
}
|
|
144
141
|
subscribe(listener) {
|
|
145
142
|
this.listeners.push(listener);
|
|
@@ -1159,7 +1156,7 @@ function appendJoin(parent, d) {
|
|
|
1159
1156
|
}
|
|
1160
1157
|
|
|
1161
1158
|
class LabelView {
|
|
1162
|
-
static create(parent, y, cfg, text, theme) {
|
|
1159
|
+
static create(parent, y, cfg, text, theme, textWidthMeasurer) {
|
|
1163
1160
|
const g = Dom.svg('g', {
|
|
1164
1161
|
class: `sqd-label sqd-label-${theme}`
|
|
1165
1162
|
});
|
|
@@ -1170,7 +1167,8 @@ class LabelView {
|
|
|
1170
1167
|
});
|
|
1171
1168
|
nameText.textContent = text;
|
|
1172
1169
|
g.appendChild(nameText);
|
|
1173
|
-
const
|
|
1170
|
+
const nameWidth = textWidthMeasurer(nameText);
|
|
1171
|
+
const width = Math.max(nameWidth + cfg.paddingX * 2, cfg.minWidth);
|
|
1174
1172
|
const nameRect = Dom.svg('rect', {
|
|
1175
1173
|
class: 'sqd-label-rect',
|
|
1176
1174
|
width: width,
|
|
@@ -1226,7 +1224,9 @@ class DefaultSequenceComponentView {
|
|
|
1226
1224
|
const { sequence } = sequenceContext;
|
|
1227
1225
|
const g = Dom.svg('g');
|
|
1228
1226
|
parent.appendChild(g);
|
|
1229
|
-
const components =
|
|
1227
|
+
const components = new Array(sequence.length);
|
|
1228
|
+
let restWidth = 0;
|
|
1229
|
+
let joinX = 0;
|
|
1230
1230
|
for (let index = 0; index < sequence.length; index++) {
|
|
1231
1231
|
const stepContext = {
|
|
1232
1232
|
parentSequence: sequenceContext.sequence,
|
|
@@ -1237,13 +1237,13 @@ class DefaultSequenceComponentView {
|
|
|
1237
1237
|
isOutputConnected: index === sequence.length - 1 ? sequenceContext.isOutputConnected : true,
|
|
1238
1238
|
isPreview: sequenceContext.isPreview
|
|
1239
1239
|
};
|
|
1240
|
-
|
|
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);
|
|
1241
1244
|
}
|
|
1242
|
-
let joinX;
|
|
1243
1245
|
let totalWidth;
|
|
1244
|
-
if (
|
|
1245
|
-
const restWidth = Math.max(...components.map(c => c.view.width - c.view.joinX));
|
|
1246
|
-
joinX = Math.max(...components.map(c => c.view.joinX));
|
|
1246
|
+
if (sequence.length > 0) {
|
|
1247
1247
|
totalWidth = joinX + restWidth;
|
|
1248
1248
|
}
|
|
1249
1249
|
else {
|
|
@@ -1475,7 +1475,7 @@ const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepCon
|
|
|
1475
1475
|
return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
|
|
1476
1476
|
const step = stepContext.step;
|
|
1477
1477
|
const name = viewContext.getStepName();
|
|
1478
|
-
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);
|
|
1479
1479
|
const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
|
|
1480
1480
|
const halfOfWidestElement = labelView.width / 2;
|
|
1481
1481
|
const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
|
|
@@ -1721,7 +1721,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
|
|
|
1721
1721
|
const step = stepContext.step;
|
|
1722
1722
|
const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
|
|
1723
1723
|
const name = viewContext.getStepName();
|
|
1724
|
-
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
|
|
1724
|
+
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary', viewContext.textWidthMeasurer);
|
|
1725
1725
|
const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
|
|
1726
1726
|
if (branchNames.length === 0) {
|
|
1727
1727
|
const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
|
|
@@ -1742,7 +1742,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
|
|
|
1742
1742
|
const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
|
|
1743
1743
|
const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
|
|
1744
1744
|
const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
|
|
1745
|
-
const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
|
|
1745
|
+
const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary', viewContext.textWidthMeasurer);
|
|
1746
1746
|
const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
|
|
1747
1747
|
const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
|
|
1748
1748
|
const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
|
|
@@ -1818,8 +1818,9 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1818
1818
|
});
|
|
1819
1819
|
text.textContent = viewContext.getStepName();
|
|
1820
1820
|
g.appendChild(text);
|
|
1821
|
-
const textWidth =
|
|
1822
|
-
const
|
|
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;
|
|
1823
1824
|
const rect = Dom.svg('rect', {
|
|
1824
1825
|
x: 0.5,
|
|
1825
1826
|
y: 0.5,
|
|
@@ -1829,7 +1830,6 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1829
1830
|
rx: cfg.radius,
|
|
1830
1831
|
ry: cfg.radius
|
|
1831
1832
|
});
|
|
1832
|
-
g.insertBefore(rect, text);
|
|
1833
1833
|
const iconUrl = viewContext.getStepIconUrl();
|
|
1834
1834
|
const icon = iconUrl
|
|
1835
1835
|
? Dom.svg('image', {
|
|
@@ -1846,6 +1846,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1846
1846
|
width: cfg.iconSize,
|
|
1847
1847
|
height: cfg.iconSize
|
|
1848
1848
|
});
|
|
1849
|
+
g.insertBefore(rect, text);
|
|
1849
1850
|
g.appendChild(icon);
|
|
1850
1851
|
const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
|
|
1851
1852
|
const isOutputViewHidden = isInterrupted;
|
|
@@ -2532,6 +2533,7 @@ class StepComponentViewContextFactory {
|
|
|
2532
2533
|
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
2533
2534
|
return {
|
|
2534
2535
|
i18n: componentContext.i18n,
|
|
2536
|
+
textWidthMeasurer: componentContext.textWidthMeasurer,
|
|
2535
2537
|
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
2536
2538
|
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
2537
2539
|
createStepComponent: (parentElement, parentSequence, step, position) => {
|
|
@@ -2586,13 +2588,13 @@ class StepComponentFactory {
|
|
|
2586
2588
|
}
|
|
2587
2589
|
|
|
2588
2590
|
class ComponentContext {
|
|
2589
|
-
static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
|
|
2591
|
+
static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services) {
|
|
2590
2592
|
const validator = new DefinitionValidator(configuration.validator, state);
|
|
2591
2593
|
const iconProvider = new IconProvider(configuration.steps);
|
|
2592
2594
|
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
2593
|
-
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);
|
|
2594
2596
|
}
|
|
2595
|
-
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state) {
|
|
2597
|
+
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state) {
|
|
2596
2598
|
this.shadowRoot = shadowRoot;
|
|
2597
2599
|
this.validator = validator;
|
|
2598
2600
|
this.iconProvider = iconProvider;
|
|
@@ -2602,6 +2604,7 @@ class ComponentContext {
|
|
|
2602
2604
|
this.services = services;
|
|
2603
2605
|
this.preferenceStorage = preferenceStorage;
|
|
2604
2606
|
this.i18n = i18n;
|
|
2607
|
+
this.textWidthMeasurer = textWidthMeasurer;
|
|
2605
2608
|
this.state = state;
|
|
2606
2609
|
}
|
|
2607
2610
|
getViewportScale() {
|
|
@@ -3322,9 +3325,13 @@ class MemoryPreferenceStorage {
|
|
|
3322
3325
|
}
|
|
3323
3326
|
}
|
|
3324
3327
|
|
|
3328
|
+
function measureTextWidth(text) {
|
|
3329
|
+
return text.getBBox().width;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3325
3332
|
class DesignerContext {
|
|
3326
3333
|
static create(placeholder, startDefinition, configuration, services) {
|
|
3327
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3334
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3328
3335
|
const definition = ObjectCloner.deepClone(startDefinition);
|
|
3329
3336
|
const layoutController = new LayoutController(placeholder);
|
|
3330
3337
|
const isReadonly = Boolean(configuration.isReadonly);
|
|
@@ -3340,13 +3347,14 @@ class DesignerContext {
|
|
|
3340
3347
|
const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new sequentialWorkflowModel.DefinitionWalker();
|
|
3341
3348
|
const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
|
|
3342
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;
|
|
3343
3351
|
const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
|
|
3344
3352
|
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
3345
3353
|
let historyController = undefined;
|
|
3346
3354
|
if (configuration.undoStackSize) {
|
|
3347
3355
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
3348
3356
|
}
|
|
3349
|
-
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);
|
|
3350
3358
|
return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
|
|
3351
3359
|
}
|
|
3352
3360
|
constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
|
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)
|
|
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);
|
|
@@ -135,10 +136,6 @@ class SimpleEvent {
|
|
|
135
136
|
listener(value);
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated Use `emit` method instead.
|
|
140
|
-
*/
|
|
141
|
-
this.forward = this.emit;
|
|
142
139
|
}
|
|
143
140
|
subscribe(listener) {
|
|
144
141
|
this.listeners.push(listener);
|
|
@@ -1158,7 +1155,7 @@ function appendJoin(parent, d) {
|
|
|
1158
1155
|
}
|
|
1159
1156
|
|
|
1160
1157
|
class LabelView {
|
|
1161
|
-
static create(parent, y, cfg, text, theme) {
|
|
1158
|
+
static create(parent, y, cfg, text, theme, textWidthMeasurer) {
|
|
1162
1159
|
const g = Dom.svg('g', {
|
|
1163
1160
|
class: `sqd-label sqd-label-${theme}`
|
|
1164
1161
|
});
|
|
@@ -1169,7 +1166,8 @@ class LabelView {
|
|
|
1169
1166
|
});
|
|
1170
1167
|
nameText.textContent = text;
|
|
1171
1168
|
g.appendChild(nameText);
|
|
1172
|
-
const
|
|
1169
|
+
const nameWidth = textWidthMeasurer(nameText);
|
|
1170
|
+
const width = Math.max(nameWidth + cfg.paddingX * 2, cfg.minWidth);
|
|
1173
1171
|
const nameRect = Dom.svg('rect', {
|
|
1174
1172
|
class: 'sqd-label-rect',
|
|
1175
1173
|
width: width,
|
|
@@ -1225,7 +1223,9 @@ class DefaultSequenceComponentView {
|
|
|
1225
1223
|
const { sequence } = sequenceContext;
|
|
1226
1224
|
const g = Dom.svg('g');
|
|
1227
1225
|
parent.appendChild(g);
|
|
1228
|
-
const components =
|
|
1226
|
+
const components = new Array(sequence.length);
|
|
1227
|
+
let restWidth = 0;
|
|
1228
|
+
let joinX = 0;
|
|
1229
1229
|
for (let index = 0; index < sequence.length; index++) {
|
|
1230
1230
|
const stepContext = {
|
|
1231
1231
|
parentSequence: sequenceContext.sequence,
|
|
@@ -1236,13 +1236,13 @@ class DefaultSequenceComponentView {
|
|
|
1236
1236
|
isOutputConnected: index === sequence.length - 1 ? sequenceContext.isOutputConnected : true,
|
|
1237
1237
|
isPreview: sequenceContext.isPreview
|
|
1238
1238
|
};
|
|
1239
|
-
|
|
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);
|
|
1240
1243
|
}
|
|
1241
|
-
let joinX;
|
|
1242
1244
|
let totalWidth;
|
|
1243
|
-
if (
|
|
1244
|
-
const restWidth = Math.max(...components.map(c => c.view.width - c.view.joinX));
|
|
1245
|
-
joinX = Math.max(...components.map(c => c.view.joinX));
|
|
1245
|
+
if (sequence.length > 0) {
|
|
1246
1246
|
totalWidth = joinX + restWidth;
|
|
1247
1247
|
}
|
|
1248
1248
|
else {
|
|
@@ -1474,7 +1474,7 @@ const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepCon
|
|
|
1474
1474
|
return viewContext.createRegionComponentView(parentElement, COMPONENT_CLASS_NAME$3, (g, regionViewBuilder) => {
|
|
1475
1475
|
const step = stepContext.step;
|
|
1476
1476
|
const name = viewContext.getStepName();
|
|
1477
|
-
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);
|
|
1478
1478
|
const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
|
|
1479
1479
|
const halfOfWidestElement = labelView.width / 2;
|
|
1480
1480
|
const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
|
|
@@ -1720,7 +1720,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
|
|
|
1720
1720
|
const step = stepContext.step;
|
|
1721
1721
|
const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
|
|
1722
1722
|
const name = viewContext.getStepName();
|
|
1723
|
-
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
|
|
1723
|
+
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary', viewContext.textWidthMeasurer);
|
|
1724
1724
|
const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
|
|
1725
1725
|
if (branchNames.length === 0) {
|
|
1726
1726
|
const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
|
|
@@ -1741,7 +1741,7 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNam
|
|
|
1741
1741
|
const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
|
|
1742
1742
|
const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
|
|
1743
1743
|
const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
|
|
1744
|
-
const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
|
|
1744
|
+
const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary', viewContext.textWidthMeasurer);
|
|
1745
1745
|
const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
|
|
1746
1746
|
const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
|
|
1747
1747
|
const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
|
|
@@ -1817,8 +1817,9 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1817
1817
|
});
|
|
1818
1818
|
text.textContent = viewContext.getStepName();
|
|
1819
1819
|
g.appendChild(text);
|
|
1820
|
-
const textWidth =
|
|
1821
|
-
const
|
|
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;
|
|
1822
1823
|
const rect = Dom.svg('rect', {
|
|
1823
1824
|
x: 0.5,
|
|
1824
1825
|
y: 0.5,
|
|
@@ -1828,7 +1829,6 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1828
1829
|
rx: cfg.radius,
|
|
1829
1830
|
ry: cfg.radius
|
|
1830
1831
|
});
|
|
1831
|
-
g.insertBefore(rect, text);
|
|
1832
1832
|
const iconUrl = viewContext.getStepIconUrl();
|
|
1833
1833
|
const icon = iconUrl
|
|
1834
1834
|
? Dom.svg('image', {
|
|
@@ -1845,6 +1845,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1845
1845
|
width: cfg.iconSize,
|
|
1846
1846
|
height: cfg.iconSize
|
|
1847
1847
|
});
|
|
1848
|
+
g.insertBefore(rect, text);
|
|
1848
1849
|
g.appendChild(icon);
|
|
1849
1850
|
const isInputViewHidden = !stepContext.isInputConnected; // TODO: handle inside the folder
|
|
1850
1851
|
const isOutputViewHidden = isInterrupted;
|
|
@@ -2531,6 +2532,7 @@ class StepComponentViewContextFactory {
|
|
|
2531
2532
|
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
2532
2533
|
return {
|
|
2533
2534
|
i18n: componentContext.i18n,
|
|
2535
|
+
textWidthMeasurer: componentContext.textWidthMeasurer,
|
|
2534
2536
|
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
2535
2537
|
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
2536
2538
|
createStepComponent: (parentElement, parentSequence, step, position) => {
|
|
@@ -2585,13 +2587,13 @@ class StepComponentFactory {
|
|
|
2585
2587
|
}
|
|
2586
2588
|
|
|
2587
2589
|
class ComponentContext {
|
|
2588
|
-
static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, services) {
|
|
2590
|
+
static create(configuration, state, stepExtensionResolver, placeholderController, definitionWalker, preferenceStorage, i18n, textWidthMeasurer, services) {
|
|
2589
2591
|
const validator = new DefinitionValidator(configuration.validator, state);
|
|
2590
2592
|
const iconProvider = new IconProvider(configuration.steps);
|
|
2591
2593
|
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
2592
|
-
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);
|
|
2593
2595
|
}
|
|
2594
|
-
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, state) {
|
|
2596
|
+
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, textWidthMeasurer, state) {
|
|
2595
2597
|
this.shadowRoot = shadowRoot;
|
|
2596
2598
|
this.validator = validator;
|
|
2597
2599
|
this.iconProvider = iconProvider;
|
|
@@ -2601,6 +2603,7 @@ class ComponentContext {
|
|
|
2601
2603
|
this.services = services;
|
|
2602
2604
|
this.preferenceStorage = preferenceStorage;
|
|
2603
2605
|
this.i18n = i18n;
|
|
2606
|
+
this.textWidthMeasurer = textWidthMeasurer;
|
|
2604
2607
|
this.state = state;
|
|
2605
2608
|
}
|
|
2606
2609
|
getViewportScale() {
|
|
@@ -3321,9 +3324,13 @@ class MemoryPreferenceStorage {
|
|
|
3321
3324
|
}
|
|
3322
3325
|
}
|
|
3323
3326
|
|
|
3327
|
+
function measureTextWidth(text) {
|
|
3328
|
+
return text.getBBox().width;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3324
3331
|
class DesignerContext {
|
|
3325
3332
|
static create(placeholder, startDefinition, configuration, services) {
|
|
3326
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3333
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3327
3334
|
const definition = ObjectCloner.deepClone(startDefinition);
|
|
3328
3335
|
const layoutController = new LayoutController(placeholder);
|
|
3329
3336
|
const isReadonly = Boolean(configuration.isReadonly);
|
|
@@ -3339,13 +3346,14 @@ class DesignerContext {
|
|
|
3339
3346
|
const definitionWalker = (_d = configuration.definitionWalker) !== null && _d !== void 0 ? _d : new DefinitionWalker();
|
|
3340
3347
|
const i18n = (_e = configuration.i18n) !== null && _e !== void 0 ? _e : ((_, defaultValue) => defaultValue);
|
|
3341
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;
|
|
3342
3350
|
const stateModifier = StateModifier.create(definitionWalker, uidGenerator, state, configuration.steps);
|
|
3343
3351
|
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
3344
3352
|
let historyController = undefined;
|
|
3345
3353
|
if (configuration.undoStackSize) {
|
|
3346
3354
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
3347
3355
|
}
|
|
3348
|
-
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);
|
|
3349
3357
|
return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
|
|
3350
3358
|
}
|
|
3351
3359
|
constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, uidGenerator, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
|
package/lib/index.d.ts
CHANGED
|
@@ -62,10 +62,6 @@ declare class SimpleEvent<T> {
|
|
|
62
62
|
subscribe(listener: SimpleEventListener<T>): void;
|
|
63
63
|
unsubscribe(listener: SimpleEventListener<T>): void;
|
|
64
64
|
readonly emit: (value: T) => void;
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated Use `emit` method instead.
|
|
67
|
-
*/
|
|
68
|
-
readonly forward: (value: T) => void;
|
|
69
65
|
count(): number;
|
|
70
66
|
once(): Promise<T>;
|
|
71
67
|
}
|
|
@@ -306,8 +302,9 @@ declare class ComponentContext {
|
|
|
306
302
|
readonly services: Services;
|
|
307
303
|
readonly preferenceStorage: PreferenceStorage;
|
|
308
304
|
readonly i18n: I18n;
|
|
305
|
+
readonly textWidthMeasurer: TextWidthMeasurer;
|
|
309
306
|
private readonly state;
|
|
310
|
-
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;
|
|
311
308
|
private constructor();
|
|
312
309
|
getViewportScale(): number;
|
|
313
310
|
}
|
|
@@ -596,7 +593,7 @@ declare class LabelView {
|
|
|
596
593
|
readonly g: SVGGElement;
|
|
597
594
|
readonly width: number;
|
|
598
595
|
readonly height: number;
|
|
599
|
-
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;
|
|
600
597
|
constructor(g: SVGGElement, width: number, height: number);
|
|
601
598
|
}
|
|
602
599
|
|
|
@@ -877,6 +874,7 @@ interface StepExtension<S extends Step = Step> {
|
|
|
877
874
|
type StepComponentViewFactory = StepExtension['createComponentView'];
|
|
878
875
|
interface StepComponentViewContext {
|
|
879
876
|
i18n: I18n;
|
|
877
|
+
textWidthMeasurer: TextWidthMeasurer;
|
|
880
878
|
getStepName(): string;
|
|
881
879
|
getStepIconUrl(): string | null;
|
|
882
880
|
createStepComponent(parentElement: SVGElement, parentSequence: Sequence, step: Step, position: number): StepComponent;
|
|
@@ -1098,6 +1096,10 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
|
|
|
1098
1096
|
* @description Custom translation function.
|
|
1099
1097
|
*/
|
|
1100
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;
|
|
1101
1103
|
/**
|
|
1102
1104
|
* @description Pass the shadow root of the shadow root to the designer if the designer is placed inside the shadow DOM.
|
|
1103
1105
|
*/
|
|
@@ -1153,6 +1155,7 @@ interface PreferenceStorage {
|
|
|
1153
1155
|
setItem(key: string, value: string): void;
|
|
1154
1156
|
getItem(key: string): string | null;
|
|
1155
1157
|
}
|
|
1158
|
+
type TextWidthMeasurer = (text: SVGTextElement) => number;
|
|
1156
1159
|
interface StepsConfiguration {
|
|
1157
1160
|
isSelectable?: (step: Step, parentSequence: Sequence) => boolean;
|
|
1158
1161
|
isDraggable?: (step: Step, parentSequence: Sequence) => boolean;
|
|
@@ -1506,4 +1509,4 @@ declare class Designer<TDefinition extends Definition = Definition> {
|
|
|
1506
1509
|
}
|
|
1507
1510
|
|
|
1508
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 };
|
|
1509
|
-
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.
|
|
4
|
+
"version": "0.38.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|