sequential-workflow-designer 0.19.0 → 0.19.2
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 +59 -60
- package/lib/cjs/index.cjs +59 -60
- package/lib/esm/index.js +59 -60
- package/lib/index.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ Pro:
|
|
|
42
42
|
* [🤩 Pro Components](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/pro-components.html)
|
|
43
43
|
* [🍬 Custom Theme Flat](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/custom-theme-flat.html)
|
|
44
44
|
* [🌹 Custom Step Types](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/custom-step-types.html)
|
|
45
|
+
* [📺 Popup Editor](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/popup-editor.html)
|
|
45
46
|
* [👈 Goto](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/goto.html)
|
|
46
47
|
* [📁 Folders](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/folders.html)
|
|
47
48
|
* [⭕ Wheel Mode](https://nocode-js.com/examples/sequential-workflow-designer-pro/webpack-pro-app/public/wheel-mode.html)
|
|
@@ -98,10 +99,10 @@ Add the below code to your head section in HTML document.
|
|
|
98
99
|
```html
|
|
99
100
|
<head>
|
|
100
101
|
...
|
|
101
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.
|
|
102
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.
|
|
103
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.
|
|
104
|
-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.
|
|
102
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.2/css/designer.css" rel="stylesheet">
|
|
103
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.2/css/designer-light.css" rel="stylesheet">
|
|
104
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.2/css/designer-dark.css" rel="stylesheet">
|
|
105
|
+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.19.2/dist/index.umd.js"></script>
|
|
105
106
|
```
|
|
106
107
|
|
|
107
108
|
Call the designer by:
|
package/dist/index.umd.js
CHANGED
|
@@ -964,9 +964,10 @@
|
|
|
964
964
|
}
|
|
965
965
|
|
|
966
966
|
class CustomActionController {
|
|
967
|
-
constructor(configuration, state) {
|
|
967
|
+
constructor(configuration, state, stateModifier) {
|
|
968
968
|
this.configuration = configuration;
|
|
969
969
|
this.state = state;
|
|
970
|
+
this.stateModifier = stateModifier;
|
|
970
971
|
}
|
|
971
972
|
trigger(action, step, sequence) {
|
|
972
973
|
const handler = this.configuration.customActionHandler;
|
|
@@ -974,20 +975,26 @@
|
|
|
974
975
|
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
975
976
|
return;
|
|
976
977
|
}
|
|
977
|
-
const context =
|
|
978
|
-
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId),
|
|
979
|
-
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId),
|
|
980
|
-
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId),
|
|
981
|
-
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId),
|
|
982
|
-
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId)
|
|
983
|
-
};
|
|
978
|
+
const context = this.createCustomActionHandlerContext();
|
|
984
979
|
handler(action, step, sequence, context);
|
|
985
980
|
}
|
|
986
|
-
|
|
981
|
+
createCustomActionHandlerContext() {
|
|
982
|
+
return {
|
|
983
|
+
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
|
|
984
|
+
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
985
|
+
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
|
|
986
|
+
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
|
|
987
|
+
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
987
991
|
if (!stepId) {
|
|
988
992
|
throw new Error('Step id is empty');
|
|
989
993
|
}
|
|
990
994
|
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
995
|
+
if (updateDependencies) {
|
|
996
|
+
this.stateModifier.updateDependencies();
|
|
997
|
+
}
|
|
991
998
|
}
|
|
992
999
|
}
|
|
993
1000
|
|
|
@@ -2656,10 +2663,10 @@
|
|
|
2656
2663
|
const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
|
|
2657
2664
|
const workspaceController = new WorkspaceControllerWrapper();
|
|
2658
2665
|
const behaviorController = new BehaviorController();
|
|
2659
|
-
const customActionController = new CustomActionController(configuration, state);
|
|
2660
2666
|
const stepExtensionResolver = StepExtensionResolver.create(services);
|
|
2661
2667
|
const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
|
|
2662
2668
|
const stateModifier = StateModifier.create(definitionWalker, state, configuration);
|
|
2669
|
+
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
2663
2670
|
let historyController = undefined;
|
|
2664
2671
|
if (configuration.undoStackSize) {
|
|
2665
2672
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
@@ -2788,7 +2795,7 @@
|
|
|
2788
2795
|
bindClick(handler) {
|
|
2789
2796
|
this.canvas.addEventListener('mousedown', e => {
|
|
2790
2797
|
e.preventDefault();
|
|
2791
|
-
handler(readMousePosition(e), e.target, e.button);
|
|
2798
|
+
handler(readMousePosition(e), e.target, e.button, e.altKey);
|
|
2792
2799
|
}, false);
|
|
2793
2800
|
this.canvas.addEventListener('touchstart', e => {
|
|
2794
2801
|
e.preventDefault();
|
|
@@ -2796,7 +2803,7 @@
|
|
|
2796
2803
|
const element = document.elementFromPoint(clientPosition.x, clientPosition.y);
|
|
2797
2804
|
if (element) {
|
|
2798
2805
|
const position = readTouchPosition(e);
|
|
2799
|
-
handler(position, element, 0);
|
|
2806
|
+
handler(position, element, 0, false);
|
|
2800
2807
|
}
|
|
2801
2808
|
}, listenerOptions$1);
|
|
2802
2809
|
}
|
|
@@ -2856,8 +2863,8 @@
|
|
|
2856
2863
|
}
|
|
2857
2864
|
|
|
2858
2865
|
class SelectStepBehavior {
|
|
2859
|
-
static create(pressedStepComponent,
|
|
2860
|
-
const isDragDisabled =
|
|
2866
|
+
static create(pressedStepComponent, forceMove, context) {
|
|
2867
|
+
const isDragDisabled = forceMove ||
|
|
2861
2868
|
context.state.isDragDisabled ||
|
|
2862
2869
|
!context.stateModifier.isDraggable(pressedStepComponent.step, pressedStepComponent.parentSequence);
|
|
2863
2870
|
return new SelectStepBehavior(pressedStepComponent, isDragDisabled, context.state, context.stateModifier, context);
|
|
@@ -2946,13 +2953,13 @@
|
|
|
2946
2953
|
constructor(context) {
|
|
2947
2954
|
this.context = context;
|
|
2948
2955
|
}
|
|
2949
|
-
resolve(commandOrNull, element,
|
|
2956
|
+
resolve(commandOrNull, element, forceMove) {
|
|
2950
2957
|
if (!commandOrNull) {
|
|
2951
|
-
return MoveViewportBehavior.create(!
|
|
2958
|
+
return MoveViewportBehavior.create(!forceMove, this.context);
|
|
2952
2959
|
}
|
|
2953
2960
|
switch (commandOrNull.type) {
|
|
2954
2961
|
case exports.ClickCommandType.selectStep:
|
|
2955
|
-
return SelectStepBehavior.create(commandOrNull.component,
|
|
2962
|
+
return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
|
|
2956
2963
|
case exports.ClickCommandType.rerenderStep:
|
|
2957
2964
|
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
|
|
2958
2965
|
case exports.ClickCommandType.openFolder:
|
|
@@ -3188,9 +3195,9 @@
|
|
|
3188
3195
|
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
|
|
3189
3196
|
workspace.onStateChanged(r[0], r[1], r[2]);
|
|
3190
3197
|
});
|
|
3191
|
-
view.bindClick(
|
|
3192
|
-
view.bindWheel(
|
|
3193
|
-
view.bindContextMenu(
|
|
3198
|
+
view.bindClick(workspace.onClick);
|
|
3199
|
+
view.bindWheel(workspace.onWheel);
|
|
3200
|
+
view.bindContextMenu(workspace.onContextMenu);
|
|
3194
3201
|
return workspace;
|
|
3195
3202
|
}
|
|
3196
3203
|
constructor(view, definitionWalker, state, behaviorController, wheelController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
@@ -3207,6 +3214,25 @@
|
|
|
3207
3214
|
this.isValid = false;
|
|
3208
3215
|
this.selectedStepComponent = null;
|
|
3209
3216
|
this.validationErrorBadgeIndex = null;
|
|
3217
|
+
this.onClick = (position, target, buttonIndex, altKey) => {
|
|
3218
|
+
const isPrimaryButton = buttonIndex === 0;
|
|
3219
|
+
const isMiddleButton = buttonIndex === 1;
|
|
3220
|
+
if (isPrimaryButton || isMiddleButton) {
|
|
3221
|
+
const forceMove = isMiddleButton || altKey;
|
|
3222
|
+
const commandOrNull = this.resolveClick(target, position);
|
|
3223
|
+
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
|
|
3224
|
+
this.behaviorController.start(position, behavior);
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
this.onWheel = (e) => {
|
|
3228
|
+
e.preventDefault();
|
|
3229
|
+
e.stopPropagation();
|
|
3230
|
+
this.wheelController.onWheel(e);
|
|
3231
|
+
};
|
|
3232
|
+
this.onContextMenu = (position, target) => {
|
|
3233
|
+
const commandOrNull = this.resolveClick(target, position);
|
|
3234
|
+
this.contextMenuController.tryOpen(position, commandOrNull);
|
|
3235
|
+
};
|
|
3210
3236
|
}
|
|
3211
3237
|
updateRootComponent() {
|
|
3212
3238
|
this.selectedStepComponent = null;
|
|
@@ -3271,24 +3297,6 @@
|
|
|
3271
3297
|
this.contextMenuController.destroy();
|
|
3272
3298
|
this.view.destroy();
|
|
3273
3299
|
}
|
|
3274
|
-
onClick(position, target, buttonIndex) {
|
|
3275
|
-
const isPrimaryButton = buttonIndex === 0;
|
|
3276
|
-
const isMiddleButton = buttonIndex === 1;
|
|
3277
|
-
if (isPrimaryButton || isMiddleButton) {
|
|
3278
|
-
const commandOrNull = this.resolveClick(target, position);
|
|
3279
|
-
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, isMiddleButton);
|
|
3280
|
-
this.behaviorController.start(position, behavior);
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
onWheel(e) {
|
|
3284
|
-
e.preventDefault();
|
|
3285
|
-
e.stopPropagation();
|
|
3286
|
-
this.wheelController.onWheel(e);
|
|
3287
|
-
}
|
|
3288
|
-
onContextMenu(position, target) {
|
|
3289
|
-
const commandOrNull = this.resolveClick(target, position);
|
|
3290
|
-
this.contextMenuController.tryOpen(position, commandOrNull);
|
|
3291
|
-
}
|
|
3292
3300
|
onIsDraggingChanged(isDragging) {
|
|
3293
3301
|
this.getRootComponent().setIsDragging(isDragging);
|
|
3294
3302
|
}
|
|
@@ -4437,25 +4445,19 @@
|
|
|
4437
4445
|
}
|
|
4438
4446
|
}
|
|
4439
4447
|
|
|
4440
|
-
function throwDepreciatedError(propertyName, groupName) {
|
|
4441
|
-
throw new Error(`The "${propertyName}" property in the "${groupName}" configuration is depreciated`);
|
|
4442
|
-
}
|
|
4443
4448
|
function validateConfiguration(configuration) {
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4452
|
-
if (configuration.editors && configuration.editors.isHidden !== undefined) {
|
|
4453
|
-
throwDepreciatedError('isHidden', 'editors');
|
|
4454
|
-
}
|
|
4455
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4456
|
-
if (configuration.steps.validator) {
|
|
4457
|
-
throwDepreciatedError('validator', 'steps');
|
|
4449
|
+
const validateProperty = (key) => {
|
|
4450
|
+
if (configuration[key] === undefined) {
|
|
4451
|
+
throw new Error(`The "${key}" property is not defined in the configuration`);
|
|
4452
|
+
}
|
|
4453
|
+
};
|
|
4454
|
+
if (!configuration) {
|
|
4455
|
+
throw new Error('Configuration is not defined');
|
|
4458
4456
|
}
|
|
4457
|
+
validateProperty('steps');
|
|
4458
|
+
validateProperty('toolbox');
|
|
4459
|
+
validateProperty('editors');
|
|
4460
|
+
validateProperty('controlBar');
|
|
4459
4461
|
}
|
|
4460
4462
|
|
|
4461
4463
|
class Designer {
|
|
@@ -4468,16 +4470,13 @@
|
|
|
4468
4470
|
*/
|
|
4469
4471
|
static create(placeholder, startDefinition, configuration) {
|
|
4470
4472
|
if (!placeholder) {
|
|
4471
|
-
throw new Error('Placeholder is not
|
|
4473
|
+
throw new Error('Placeholder is not defined');
|
|
4472
4474
|
}
|
|
4473
4475
|
if (!isElementAttached(placeholder)) {
|
|
4474
4476
|
throw new Error('Placeholder is not attached to the DOM');
|
|
4475
4477
|
}
|
|
4476
4478
|
if (!startDefinition) {
|
|
4477
|
-
throw new Error('Start definition is not
|
|
4478
|
-
}
|
|
4479
|
-
if (!configuration) {
|
|
4480
|
-
throw new Error('Configuration is not set');
|
|
4479
|
+
throw new Error('Start definition is not defined');
|
|
4481
4480
|
}
|
|
4482
4481
|
const config = configuration;
|
|
4483
4482
|
validateConfiguration(config);
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -962,9 +962,10 @@ class ComponentContext {
|
|
|
962
962
|
}
|
|
963
963
|
|
|
964
964
|
class CustomActionController {
|
|
965
|
-
constructor(configuration, state) {
|
|
965
|
+
constructor(configuration, state, stateModifier) {
|
|
966
966
|
this.configuration = configuration;
|
|
967
967
|
this.state = state;
|
|
968
|
+
this.stateModifier = stateModifier;
|
|
968
969
|
}
|
|
969
970
|
trigger(action, step, sequence) {
|
|
970
971
|
const handler = this.configuration.customActionHandler;
|
|
@@ -972,20 +973,26 @@ class CustomActionController {
|
|
|
972
973
|
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
973
974
|
return;
|
|
974
975
|
}
|
|
975
|
-
const context =
|
|
976
|
-
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId),
|
|
977
|
-
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId),
|
|
978
|
-
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId),
|
|
979
|
-
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId),
|
|
980
|
-
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId)
|
|
981
|
-
};
|
|
976
|
+
const context = this.createCustomActionHandlerContext();
|
|
982
977
|
handler(action, step, sequence, context);
|
|
983
978
|
}
|
|
984
|
-
|
|
979
|
+
createCustomActionHandlerContext() {
|
|
980
|
+
return {
|
|
981
|
+
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
|
|
982
|
+
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
983
|
+
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
|
|
984
|
+
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
|
|
985
|
+
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
985
989
|
if (!stepId) {
|
|
986
990
|
throw new Error('Step id is empty');
|
|
987
991
|
}
|
|
988
992
|
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
993
|
+
if (updateDependencies) {
|
|
994
|
+
this.stateModifier.updateDependencies();
|
|
995
|
+
}
|
|
989
996
|
}
|
|
990
997
|
}
|
|
991
998
|
|
|
@@ -2471,10 +2478,10 @@ class DesignerContext {
|
|
|
2471
2478
|
const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
|
|
2472
2479
|
const workspaceController = new WorkspaceControllerWrapper();
|
|
2473
2480
|
const behaviorController = new BehaviorController();
|
|
2474
|
-
const customActionController = new CustomActionController(configuration, state);
|
|
2475
2481
|
const stepExtensionResolver = StepExtensionResolver.create(services);
|
|
2476
2482
|
const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new sequentialWorkflowModel.DefinitionWalker();
|
|
2477
2483
|
const stateModifier = StateModifier.create(definitionWalker, state, configuration);
|
|
2484
|
+
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
2478
2485
|
let historyController = undefined;
|
|
2479
2486
|
if (configuration.undoStackSize) {
|
|
2480
2487
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
@@ -2603,7 +2610,7 @@ class WorkspaceView {
|
|
|
2603
2610
|
bindClick(handler) {
|
|
2604
2611
|
this.canvas.addEventListener('mousedown', e => {
|
|
2605
2612
|
e.preventDefault();
|
|
2606
|
-
handler(readMousePosition(e), e.target, e.button);
|
|
2613
|
+
handler(readMousePosition(e), e.target, e.button, e.altKey);
|
|
2607
2614
|
}, false);
|
|
2608
2615
|
this.canvas.addEventListener('touchstart', e => {
|
|
2609
2616
|
e.preventDefault();
|
|
@@ -2611,7 +2618,7 @@ class WorkspaceView {
|
|
|
2611
2618
|
const element = document.elementFromPoint(clientPosition.x, clientPosition.y);
|
|
2612
2619
|
if (element) {
|
|
2613
2620
|
const position = readTouchPosition(e);
|
|
2614
|
-
handler(position, element, 0);
|
|
2621
|
+
handler(position, element, 0, false);
|
|
2615
2622
|
}
|
|
2616
2623
|
}, listenerOptions$1);
|
|
2617
2624
|
}
|
|
@@ -2671,8 +2678,8 @@ class MoveViewportBehavior {
|
|
|
2671
2678
|
}
|
|
2672
2679
|
|
|
2673
2680
|
class SelectStepBehavior {
|
|
2674
|
-
static create(pressedStepComponent,
|
|
2675
|
-
const isDragDisabled =
|
|
2681
|
+
static create(pressedStepComponent, forceMove, context) {
|
|
2682
|
+
const isDragDisabled = forceMove ||
|
|
2676
2683
|
context.state.isDragDisabled ||
|
|
2677
2684
|
!context.stateModifier.isDraggable(pressedStepComponent.step, pressedStepComponent.parentSequence);
|
|
2678
2685
|
return new SelectStepBehavior(pressedStepComponent, isDragDisabled, context.state, context.stateModifier, context);
|
|
@@ -2761,13 +2768,13 @@ class ClickBehaviorResolver {
|
|
|
2761
2768
|
constructor(context) {
|
|
2762
2769
|
this.context = context;
|
|
2763
2770
|
}
|
|
2764
|
-
resolve(commandOrNull, element,
|
|
2771
|
+
resolve(commandOrNull, element, forceMove) {
|
|
2765
2772
|
if (!commandOrNull) {
|
|
2766
|
-
return MoveViewportBehavior.create(!
|
|
2773
|
+
return MoveViewportBehavior.create(!forceMove, this.context);
|
|
2767
2774
|
}
|
|
2768
2775
|
switch (commandOrNull.type) {
|
|
2769
2776
|
case exports.ClickCommandType.selectStep:
|
|
2770
|
-
return SelectStepBehavior.create(commandOrNull.component,
|
|
2777
|
+
return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
|
|
2771
2778
|
case exports.ClickCommandType.rerenderStep:
|
|
2772
2779
|
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
|
|
2773
2780
|
case exports.ClickCommandType.openFolder:
|
|
@@ -3003,9 +3010,9 @@ class Workspace {
|
|
|
3003
3010
|
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
|
|
3004
3011
|
workspace.onStateChanged(r[0], r[1], r[2]);
|
|
3005
3012
|
});
|
|
3006
|
-
view.bindClick(
|
|
3007
|
-
view.bindWheel(
|
|
3008
|
-
view.bindContextMenu(
|
|
3013
|
+
view.bindClick(workspace.onClick);
|
|
3014
|
+
view.bindWheel(workspace.onWheel);
|
|
3015
|
+
view.bindContextMenu(workspace.onContextMenu);
|
|
3009
3016
|
return workspace;
|
|
3010
3017
|
}
|
|
3011
3018
|
constructor(view, definitionWalker, state, behaviorController, wheelController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
@@ -3022,6 +3029,25 @@ class Workspace {
|
|
|
3022
3029
|
this.isValid = false;
|
|
3023
3030
|
this.selectedStepComponent = null;
|
|
3024
3031
|
this.validationErrorBadgeIndex = null;
|
|
3032
|
+
this.onClick = (position, target, buttonIndex, altKey) => {
|
|
3033
|
+
const isPrimaryButton = buttonIndex === 0;
|
|
3034
|
+
const isMiddleButton = buttonIndex === 1;
|
|
3035
|
+
if (isPrimaryButton || isMiddleButton) {
|
|
3036
|
+
const forceMove = isMiddleButton || altKey;
|
|
3037
|
+
const commandOrNull = this.resolveClick(target, position);
|
|
3038
|
+
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
|
|
3039
|
+
this.behaviorController.start(position, behavior);
|
|
3040
|
+
}
|
|
3041
|
+
};
|
|
3042
|
+
this.onWheel = (e) => {
|
|
3043
|
+
e.preventDefault();
|
|
3044
|
+
e.stopPropagation();
|
|
3045
|
+
this.wheelController.onWheel(e);
|
|
3046
|
+
};
|
|
3047
|
+
this.onContextMenu = (position, target) => {
|
|
3048
|
+
const commandOrNull = this.resolveClick(target, position);
|
|
3049
|
+
this.contextMenuController.tryOpen(position, commandOrNull);
|
|
3050
|
+
};
|
|
3025
3051
|
}
|
|
3026
3052
|
updateRootComponent() {
|
|
3027
3053
|
this.selectedStepComponent = null;
|
|
@@ -3086,24 +3112,6 @@ class Workspace {
|
|
|
3086
3112
|
this.contextMenuController.destroy();
|
|
3087
3113
|
this.view.destroy();
|
|
3088
3114
|
}
|
|
3089
|
-
onClick(position, target, buttonIndex) {
|
|
3090
|
-
const isPrimaryButton = buttonIndex === 0;
|
|
3091
|
-
const isMiddleButton = buttonIndex === 1;
|
|
3092
|
-
if (isPrimaryButton || isMiddleButton) {
|
|
3093
|
-
const commandOrNull = this.resolveClick(target, position);
|
|
3094
|
-
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, isMiddleButton);
|
|
3095
|
-
this.behaviorController.start(position, behavior);
|
|
3096
|
-
}
|
|
3097
|
-
}
|
|
3098
|
-
onWheel(e) {
|
|
3099
|
-
e.preventDefault();
|
|
3100
|
-
e.stopPropagation();
|
|
3101
|
-
this.wheelController.onWheel(e);
|
|
3102
|
-
}
|
|
3103
|
-
onContextMenu(position, target) {
|
|
3104
|
-
const commandOrNull = this.resolveClick(target, position);
|
|
3105
|
-
this.contextMenuController.tryOpen(position, commandOrNull);
|
|
3106
|
-
}
|
|
3107
3115
|
onIsDraggingChanged(isDragging) {
|
|
3108
3116
|
this.getRootComponent().setIsDragging(isDragging);
|
|
3109
3117
|
}
|
|
@@ -4252,25 +4260,19 @@ function setDefaults(services, configuration) {
|
|
|
4252
4260
|
}
|
|
4253
4261
|
}
|
|
4254
4262
|
|
|
4255
|
-
function throwDepreciatedError(propertyName, groupName) {
|
|
4256
|
-
throw new Error(`The "${propertyName}" property in the "${groupName}" configuration is depreciated`);
|
|
4257
|
-
}
|
|
4258
4263
|
function validateConfiguration(configuration) {
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4267
|
-
if (configuration.editors && configuration.editors.isHidden !== undefined) {
|
|
4268
|
-
throwDepreciatedError('isHidden', 'editors');
|
|
4269
|
-
}
|
|
4270
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4271
|
-
if (configuration.steps.validator) {
|
|
4272
|
-
throwDepreciatedError('validator', 'steps');
|
|
4264
|
+
const validateProperty = (key) => {
|
|
4265
|
+
if (configuration[key] === undefined) {
|
|
4266
|
+
throw new Error(`The "${key}" property is not defined in the configuration`);
|
|
4267
|
+
}
|
|
4268
|
+
};
|
|
4269
|
+
if (!configuration) {
|
|
4270
|
+
throw new Error('Configuration is not defined');
|
|
4273
4271
|
}
|
|
4272
|
+
validateProperty('steps');
|
|
4273
|
+
validateProperty('toolbox');
|
|
4274
|
+
validateProperty('editors');
|
|
4275
|
+
validateProperty('controlBar');
|
|
4274
4276
|
}
|
|
4275
4277
|
|
|
4276
4278
|
class Designer {
|
|
@@ -4283,16 +4285,13 @@ class Designer {
|
|
|
4283
4285
|
*/
|
|
4284
4286
|
static create(placeholder, startDefinition, configuration) {
|
|
4285
4287
|
if (!placeholder) {
|
|
4286
|
-
throw new Error('Placeholder is not
|
|
4288
|
+
throw new Error('Placeholder is not defined');
|
|
4287
4289
|
}
|
|
4288
4290
|
if (!isElementAttached(placeholder)) {
|
|
4289
4291
|
throw new Error('Placeholder is not attached to the DOM');
|
|
4290
4292
|
}
|
|
4291
4293
|
if (!startDefinition) {
|
|
4292
|
-
throw new Error('Start definition is not
|
|
4293
|
-
}
|
|
4294
|
-
if (!configuration) {
|
|
4295
|
-
throw new Error('Configuration is not set');
|
|
4294
|
+
throw new Error('Start definition is not defined');
|
|
4296
4295
|
}
|
|
4297
4296
|
const config = configuration;
|
|
4298
4297
|
validateConfiguration(config);
|
package/lib/esm/index.js
CHANGED
|
@@ -961,9 +961,10 @@ class ComponentContext {
|
|
|
961
961
|
}
|
|
962
962
|
|
|
963
963
|
class CustomActionController {
|
|
964
|
-
constructor(configuration, state) {
|
|
964
|
+
constructor(configuration, state, stateModifier) {
|
|
965
965
|
this.configuration = configuration;
|
|
966
966
|
this.state = state;
|
|
967
|
+
this.stateModifier = stateModifier;
|
|
967
968
|
}
|
|
968
969
|
trigger(action, step, sequence) {
|
|
969
970
|
const handler = this.configuration.customActionHandler;
|
|
@@ -971,20 +972,26 @@ class CustomActionController {
|
|
|
971
972
|
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
972
973
|
return;
|
|
973
974
|
}
|
|
974
|
-
const context =
|
|
975
|
-
notifyStepNameChanged: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepNameChanged, stepId),
|
|
976
|
-
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepPropertyChanged, stepId),
|
|
977
|
-
notifyStepInserted: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepInserted, stepId),
|
|
978
|
-
notifyStepMoved: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepMoved, stepId),
|
|
979
|
-
notifyStepDeleted: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepDeleted, stepId)
|
|
980
|
-
};
|
|
975
|
+
const context = this.createCustomActionHandlerContext();
|
|
981
976
|
handler(action, step, sequence, context);
|
|
982
977
|
}
|
|
983
|
-
|
|
978
|
+
createCustomActionHandlerContext() {
|
|
979
|
+
return {
|
|
980
|
+
notifyStepNameChanged: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepNameChanged, stepId, false),
|
|
981
|
+
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
982
|
+
notifyStepInserted: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepInserted, stepId, true),
|
|
983
|
+
notifyStepMoved: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepMoved, stepId, true),
|
|
984
|
+
notifyStepDeleted: (stepId) => this.notifyStepChanged(DefinitionChangeType.stepDeleted, stepId, true)
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
984
988
|
if (!stepId) {
|
|
985
989
|
throw new Error('Step id is empty');
|
|
986
990
|
}
|
|
987
991
|
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
992
|
+
if (updateDependencies) {
|
|
993
|
+
this.stateModifier.updateDependencies();
|
|
994
|
+
}
|
|
988
995
|
}
|
|
989
996
|
}
|
|
990
997
|
|
|
@@ -2470,10 +2477,10 @@ class DesignerContext {
|
|
|
2470
2477
|
const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
|
|
2471
2478
|
const workspaceController = new WorkspaceControllerWrapper();
|
|
2472
2479
|
const behaviorController = new BehaviorController();
|
|
2473
|
-
const customActionController = new CustomActionController(configuration, state);
|
|
2474
2480
|
const stepExtensionResolver = StepExtensionResolver.create(services);
|
|
2475
2481
|
const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
|
|
2476
2482
|
const stateModifier = StateModifier.create(definitionWalker, state, configuration);
|
|
2483
|
+
const customActionController = new CustomActionController(configuration, state, stateModifier);
|
|
2477
2484
|
let historyController = undefined;
|
|
2478
2485
|
if (configuration.undoStackSize) {
|
|
2479
2486
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
@@ -2602,7 +2609,7 @@ class WorkspaceView {
|
|
|
2602
2609
|
bindClick(handler) {
|
|
2603
2610
|
this.canvas.addEventListener('mousedown', e => {
|
|
2604
2611
|
e.preventDefault();
|
|
2605
|
-
handler(readMousePosition(e), e.target, e.button);
|
|
2612
|
+
handler(readMousePosition(e), e.target, e.button, e.altKey);
|
|
2606
2613
|
}, false);
|
|
2607
2614
|
this.canvas.addEventListener('touchstart', e => {
|
|
2608
2615
|
e.preventDefault();
|
|
@@ -2610,7 +2617,7 @@ class WorkspaceView {
|
|
|
2610
2617
|
const element = document.elementFromPoint(clientPosition.x, clientPosition.y);
|
|
2611
2618
|
if (element) {
|
|
2612
2619
|
const position = readTouchPosition(e);
|
|
2613
|
-
handler(position, element, 0);
|
|
2620
|
+
handler(position, element, 0, false);
|
|
2614
2621
|
}
|
|
2615
2622
|
}, listenerOptions$1);
|
|
2616
2623
|
}
|
|
@@ -2670,8 +2677,8 @@ class MoveViewportBehavior {
|
|
|
2670
2677
|
}
|
|
2671
2678
|
|
|
2672
2679
|
class SelectStepBehavior {
|
|
2673
|
-
static create(pressedStepComponent,
|
|
2674
|
-
const isDragDisabled =
|
|
2680
|
+
static create(pressedStepComponent, forceMove, context) {
|
|
2681
|
+
const isDragDisabled = forceMove ||
|
|
2675
2682
|
context.state.isDragDisabled ||
|
|
2676
2683
|
!context.stateModifier.isDraggable(pressedStepComponent.step, pressedStepComponent.parentSequence);
|
|
2677
2684
|
return new SelectStepBehavior(pressedStepComponent, isDragDisabled, context.state, context.stateModifier, context);
|
|
@@ -2760,13 +2767,13 @@ class ClickBehaviorResolver {
|
|
|
2760
2767
|
constructor(context) {
|
|
2761
2768
|
this.context = context;
|
|
2762
2769
|
}
|
|
2763
|
-
resolve(commandOrNull, element,
|
|
2770
|
+
resolve(commandOrNull, element, forceMove) {
|
|
2764
2771
|
if (!commandOrNull) {
|
|
2765
|
-
return MoveViewportBehavior.create(!
|
|
2772
|
+
return MoveViewportBehavior.create(!forceMove, this.context);
|
|
2766
2773
|
}
|
|
2767
2774
|
switch (commandOrNull.type) {
|
|
2768
2775
|
case ClickCommandType.selectStep:
|
|
2769
|
-
return SelectStepBehavior.create(commandOrNull.component,
|
|
2776
|
+
return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
|
|
2770
2777
|
case ClickCommandType.rerenderStep:
|
|
2771
2778
|
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
|
|
2772
2779
|
case ClickCommandType.openFolder:
|
|
@@ -3002,9 +3009,9 @@ class Workspace {
|
|
|
3002
3009
|
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
|
|
3003
3010
|
workspace.onStateChanged(r[0], r[1], r[2]);
|
|
3004
3011
|
});
|
|
3005
|
-
view.bindClick(
|
|
3006
|
-
view.bindWheel(
|
|
3007
|
-
view.bindContextMenu(
|
|
3012
|
+
view.bindClick(workspace.onClick);
|
|
3013
|
+
view.bindWheel(workspace.onWheel);
|
|
3014
|
+
view.bindContextMenu(workspace.onContextMenu);
|
|
3008
3015
|
return workspace;
|
|
3009
3016
|
}
|
|
3010
3017
|
constructor(view, definitionWalker, state, behaviorController, wheelController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
@@ -3021,6 +3028,25 @@ class Workspace {
|
|
|
3021
3028
|
this.isValid = false;
|
|
3022
3029
|
this.selectedStepComponent = null;
|
|
3023
3030
|
this.validationErrorBadgeIndex = null;
|
|
3031
|
+
this.onClick = (position, target, buttonIndex, altKey) => {
|
|
3032
|
+
const isPrimaryButton = buttonIndex === 0;
|
|
3033
|
+
const isMiddleButton = buttonIndex === 1;
|
|
3034
|
+
if (isPrimaryButton || isMiddleButton) {
|
|
3035
|
+
const forceMove = isMiddleButton || altKey;
|
|
3036
|
+
const commandOrNull = this.resolveClick(target, position);
|
|
3037
|
+
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
|
|
3038
|
+
this.behaviorController.start(position, behavior);
|
|
3039
|
+
}
|
|
3040
|
+
};
|
|
3041
|
+
this.onWheel = (e) => {
|
|
3042
|
+
e.preventDefault();
|
|
3043
|
+
e.stopPropagation();
|
|
3044
|
+
this.wheelController.onWheel(e);
|
|
3045
|
+
};
|
|
3046
|
+
this.onContextMenu = (position, target) => {
|
|
3047
|
+
const commandOrNull = this.resolveClick(target, position);
|
|
3048
|
+
this.contextMenuController.tryOpen(position, commandOrNull);
|
|
3049
|
+
};
|
|
3024
3050
|
}
|
|
3025
3051
|
updateRootComponent() {
|
|
3026
3052
|
this.selectedStepComponent = null;
|
|
@@ -3085,24 +3111,6 @@ class Workspace {
|
|
|
3085
3111
|
this.contextMenuController.destroy();
|
|
3086
3112
|
this.view.destroy();
|
|
3087
3113
|
}
|
|
3088
|
-
onClick(position, target, buttonIndex) {
|
|
3089
|
-
const isPrimaryButton = buttonIndex === 0;
|
|
3090
|
-
const isMiddleButton = buttonIndex === 1;
|
|
3091
|
-
if (isPrimaryButton || isMiddleButton) {
|
|
3092
|
-
const commandOrNull = this.resolveClick(target, position);
|
|
3093
|
-
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, isMiddleButton);
|
|
3094
|
-
this.behaviorController.start(position, behavior);
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3097
|
-
onWheel(e) {
|
|
3098
|
-
e.preventDefault();
|
|
3099
|
-
e.stopPropagation();
|
|
3100
|
-
this.wheelController.onWheel(e);
|
|
3101
|
-
}
|
|
3102
|
-
onContextMenu(position, target) {
|
|
3103
|
-
const commandOrNull = this.resolveClick(target, position);
|
|
3104
|
-
this.contextMenuController.tryOpen(position, commandOrNull);
|
|
3105
|
-
}
|
|
3106
3114
|
onIsDraggingChanged(isDragging) {
|
|
3107
3115
|
this.getRootComponent().setIsDragging(isDragging);
|
|
3108
3116
|
}
|
|
@@ -4251,25 +4259,19 @@ function setDefaults(services, configuration) {
|
|
|
4251
4259
|
}
|
|
4252
4260
|
}
|
|
4253
4261
|
|
|
4254
|
-
function throwDepreciatedError(propertyName, groupName) {
|
|
4255
|
-
throw new Error(`The "${propertyName}" property in the "${groupName}" configuration is depreciated`);
|
|
4256
|
-
}
|
|
4257
4262
|
function validateConfiguration(configuration) {
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4266
|
-
if (configuration.editors && configuration.editors.isHidden !== undefined) {
|
|
4267
|
-
throwDepreciatedError('isHidden', 'editors');
|
|
4268
|
-
}
|
|
4269
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4270
|
-
if (configuration.steps.validator) {
|
|
4271
|
-
throwDepreciatedError('validator', 'steps');
|
|
4263
|
+
const validateProperty = (key) => {
|
|
4264
|
+
if (configuration[key] === undefined) {
|
|
4265
|
+
throw new Error(`The "${key}" property is not defined in the configuration`);
|
|
4266
|
+
}
|
|
4267
|
+
};
|
|
4268
|
+
if (!configuration) {
|
|
4269
|
+
throw new Error('Configuration is not defined');
|
|
4272
4270
|
}
|
|
4271
|
+
validateProperty('steps');
|
|
4272
|
+
validateProperty('toolbox');
|
|
4273
|
+
validateProperty('editors');
|
|
4274
|
+
validateProperty('controlBar');
|
|
4273
4275
|
}
|
|
4274
4276
|
|
|
4275
4277
|
class Designer {
|
|
@@ -4282,16 +4284,13 @@ class Designer {
|
|
|
4282
4284
|
*/
|
|
4283
4285
|
static create(placeholder, startDefinition, configuration) {
|
|
4284
4286
|
if (!placeholder) {
|
|
4285
|
-
throw new Error('Placeholder is not
|
|
4287
|
+
throw new Error('Placeholder is not defined');
|
|
4286
4288
|
}
|
|
4287
4289
|
if (!isElementAttached(placeholder)) {
|
|
4288
4290
|
throw new Error('Placeholder is not attached to the DOM');
|
|
4289
4291
|
}
|
|
4290
4292
|
if (!startDefinition) {
|
|
4291
|
-
throw new Error('Start definition is not
|
|
4292
|
-
}
|
|
4293
|
-
if (!configuration) {
|
|
4294
|
-
throw new Error('Configuration is not set');
|
|
4293
|
+
throw new Error('Start definition is not defined');
|
|
4295
4294
|
}
|
|
4296
4295
|
const config = configuration;
|
|
4297
4296
|
validateConfiguration(config);
|
package/lib/index.d.ts
CHANGED
|
@@ -280,8 +280,10 @@ declare class ComponentContext {
|
|
|
280
280
|
declare class CustomActionController {
|
|
281
281
|
private readonly configuration;
|
|
282
282
|
private readonly state;
|
|
283
|
-
|
|
283
|
+
private readonly stateModifier;
|
|
284
|
+
constructor(configuration: DesignerConfiguration, state: DesignerState, stateModifier: StateModifier);
|
|
284
285
|
trigger(action: CustomAction, step: Step | null, sequence: Sequence): void;
|
|
286
|
+
private createCustomActionHandlerContext;
|
|
285
287
|
private notifyStepChanged;
|
|
286
288
|
}
|
|
287
289
|
|
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.19.
|
|
4
|
+
"version": "0.19.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|