sequential-workflow-designer 0.38.2 → 0.39.1
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 +13 -13
- package/dist/index.umd.js +116 -73
- package/lib/cjs/index.cjs +116 -73
- package/lib/esm/index.js +116 -73
- package/lib/index.d.ts +68 -34
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -201,15 +201,17 @@ function race(timeout, a, b, c, d) {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
class ControlBarApi {
|
|
204
|
-
static create(state, historyController, stateModifier) {
|
|
205
|
-
const api = new ControlBarApi(state, historyController, stateModifier);
|
|
204
|
+
static create(state, historyController, customActionController, stateModifier, configuration) {
|
|
205
|
+
const api = new ControlBarApi(state, historyController, customActionController, stateModifier, configuration);
|
|
206
206
|
race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.emit);
|
|
207
207
|
return api;
|
|
208
208
|
}
|
|
209
|
-
constructor(state, historyController, stateModifier) {
|
|
209
|
+
constructor(state, historyController, customActionController, stateModifier, configuration) {
|
|
210
210
|
this.state = state;
|
|
211
211
|
this.historyController = historyController;
|
|
212
|
+
this.customActionController = customActionController;
|
|
212
213
|
this.stateModifier = stateModifier;
|
|
214
|
+
this.configuration = configuration;
|
|
213
215
|
this.onStateChanged = new SimpleEvent();
|
|
214
216
|
}
|
|
215
217
|
isDragDisabled() {
|
|
@@ -256,6 +258,16 @@ class ControlBarApi {
|
|
|
256
258
|
!this.state.isDragging &&
|
|
257
259
|
this.stateModifier.isDeletableById(this.state.selectedStepId));
|
|
258
260
|
}
|
|
261
|
+
getButtons() {
|
|
262
|
+
return typeof this.configuration === 'boolean' ? null : this.configuration.buttons || null;
|
|
263
|
+
}
|
|
264
|
+
triggerButtonClick(id) {
|
|
265
|
+
const action = {
|
|
266
|
+
type: 'controlBarButtonClicked',
|
|
267
|
+
id
|
|
268
|
+
};
|
|
269
|
+
this.customActionController.trigger(action, null, this.state.definition.sequence);
|
|
270
|
+
}
|
|
259
271
|
}
|
|
260
272
|
|
|
261
273
|
exports.KeyboardAction = void 0;
|
|
@@ -826,7 +838,7 @@ class DesignerApi {
|
|
|
826
838
|
const workspace = new WorkspaceApi(context.state, context.definitionWalker, context.workspaceController);
|
|
827
839
|
const viewportController = context.services.viewportController.create(workspace);
|
|
828
840
|
const toolboxDataProvider = new ToolboxDataProvider(context.i18n, context.componentContext.iconProvider, context.configuration.toolbox);
|
|
829
|
-
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
841
|
+
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.customActionController, context.stateModifier, context.configuration.controlBar), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
830
842
|
}
|
|
831
843
|
constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
|
|
832
844
|
this.shadowRoot = shadowRoot;
|
|
@@ -3788,6 +3800,7 @@ class ContextMenuController {
|
|
|
3788
3800
|
this.itemsBuilder = itemsBuilder;
|
|
3789
3801
|
}
|
|
3790
3802
|
tryOpen(position, commandOrNull) {
|
|
3803
|
+
var _a, _b;
|
|
3791
3804
|
if (this.configuration.contextMenu === false) {
|
|
3792
3805
|
// Context menu is disabled.
|
|
3793
3806
|
return;
|
|
@@ -3795,8 +3808,11 @@ class ContextMenuController {
|
|
|
3795
3808
|
if (this.current) {
|
|
3796
3809
|
this.current.tryDestroy();
|
|
3797
3810
|
}
|
|
3798
|
-
const
|
|
3799
|
-
|
|
3811
|
+
const isResetViewDisabled = this.configuration.contextMenu === true ? false : (_b = (_a = this.configuration.contextMenu) === null || _a === void 0 ? void 0 : _a.isResetViewDisabled) !== null && _b !== void 0 ? _b : false;
|
|
3812
|
+
const items = this.itemsBuilder.build(commandOrNull, isResetViewDisabled);
|
|
3813
|
+
if (items.length > 0) {
|
|
3814
|
+
this.current = ContextMenu.create(this.configuration.shadowRoot, position, this.theme, items);
|
|
3815
|
+
}
|
|
3800
3816
|
}
|
|
3801
3817
|
destroy() {
|
|
3802
3818
|
if (this.current) {
|
|
@@ -3814,7 +3830,7 @@ class ContextMenuItemsBuilder {
|
|
|
3814
3830
|
this.state = state;
|
|
3815
3831
|
this.customMenuItemsProvider = customMenuItemsProvider;
|
|
3816
3832
|
}
|
|
3817
|
-
build(commandOrNull) {
|
|
3833
|
+
build(commandOrNull, isResetViewDisabled) {
|
|
3818
3834
|
const items = [];
|
|
3819
3835
|
if (commandOrNull && commandOrNull.type === exports.ClickCommandType.selectStep) {
|
|
3820
3836
|
const ssc = commandOrNull;
|
|
@@ -3871,13 +3887,15 @@ class ContextMenuItemsBuilder {
|
|
|
3871
3887
|
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3872
3888
|
this.tryAppendCustomItems(items, null, rootSequence.sequence);
|
|
3873
3889
|
}
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3890
|
+
if (!isResetViewDisabled) {
|
|
3891
|
+
items.push({
|
|
3892
|
+
label: this.i18n('contextMenu.resetView', 'Reset view'),
|
|
3893
|
+
order: 50,
|
|
3894
|
+
callback: () => {
|
|
3895
|
+
this.viewportApi.resetViewport();
|
|
3896
|
+
}
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3881
3899
|
items.sort((a, b) => a.order - b.order);
|
|
3882
3900
|
return items;
|
|
3883
3901
|
}
|
|
@@ -4236,7 +4254,7 @@ class DefaultDraggedComponentExtension {
|
|
|
4236
4254
|
}
|
|
4237
4255
|
|
|
4238
4256
|
class ControlBarView {
|
|
4239
|
-
static create(parent, isUndoRedoSupported, i18n) {
|
|
4257
|
+
static create(parent, isUndoRedoSupported, buttons, i18n) {
|
|
4240
4258
|
const root = Dom.element('div', {
|
|
4241
4259
|
class: 'sqd-control-bar'
|
|
4242
4260
|
});
|
|
@@ -4261,10 +4279,19 @@ class ControlBarView {
|
|
|
4261
4279
|
deleteButton.classList.add('sqd-delete');
|
|
4262
4280
|
deleteButton.classList.add('sqd-hidden');
|
|
4263
4281
|
root.appendChild(deleteButton);
|
|
4282
|
+
const customButtons = [];
|
|
4283
|
+
if (buttons) {
|
|
4284
|
+
for (const customButton of buttons) {
|
|
4285
|
+
const button = createButton(customButton.iconD, customButton.label);
|
|
4286
|
+
button.setAttribute('data-id', customButton.id);
|
|
4287
|
+
root.appendChild(button);
|
|
4288
|
+
customButtons.push(button);
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4264
4291
|
parent.appendChild(root);
|
|
4265
|
-
return new ControlBarView(resetButton, zoomInButton, zoomOutButton, undoButton, redoButton, disableDragButton, deleteButton);
|
|
4292
|
+
return new ControlBarView(resetButton, zoomInButton, zoomOutButton, undoButton, redoButton, disableDragButton, deleteButton, customButtons);
|
|
4266
4293
|
}
|
|
4267
|
-
constructor(resetButton, zoomInButton, zoomOutButton, undoButton, redoButton, disableDragButton, deleteButton) {
|
|
4294
|
+
constructor(resetButton, zoomInButton, zoomOutButton, undoButton, redoButton, disableDragButton, deleteButton, customButtons) {
|
|
4268
4295
|
this.resetButton = resetButton;
|
|
4269
4296
|
this.zoomInButton = zoomInButton;
|
|
4270
4297
|
this.zoomOutButton = zoomOutButton;
|
|
@@ -4272,6 +4299,7 @@ class ControlBarView {
|
|
|
4272
4299
|
this.redoButton = redoButton;
|
|
4273
4300
|
this.disableDragButton = disableDragButton;
|
|
4274
4301
|
this.deleteButton = deleteButton;
|
|
4302
|
+
this.customButtons = customButtons;
|
|
4275
4303
|
}
|
|
4276
4304
|
bindResetButtonClick(handler) {
|
|
4277
4305
|
bindClick(this.resetButton, handler);
|
|
@@ -4300,6 +4328,14 @@ class ControlBarView {
|
|
|
4300
4328
|
bindDeleteButtonClick(handler) {
|
|
4301
4329
|
bindClick(this.deleteButton, handler);
|
|
4302
4330
|
}
|
|
4331
|
+
bindCustomButtonClick(handler) {
|
|
4332
|
+
for (const customButton of this.customButtons) {
|
|
4333
|
+
const id = customButton.getAttribute('data-id');
|
|
4334
|
+
if (id) {
|
|
4335
|
+
bindClick(customButton, () => handler(id));
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4303
4339
|
setIsDeleteButtonHidden(isHidden) {
|
|
4304
4340
|
Dom.toggleClass(this.deleteButton, isHidden, 'sqd-hidden');
|
|
4305
4341
|
}
|
|
@@ -4338,17 +4374,21 @@ function createButton(d, title) {
|
|
|
4338
4374
|
class ControlBar {
|
|
4339
4375
|
static create(parent, api) {
|
|
4340
4376
|
const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
|
|
4341
|
-
const
|
|
4377
|
+
const customButtons = api.controlBar.getButtons();
|
|
4378
|
+
const view = ControlBarView.create(parent, isUndoRedoSupported, customButtons, api.i18n);
|
|
4342
4379
|
const bar = new ControlBar(view, api.controlBar, api.viewport, isUndoRedoSupported);
|
|
4343
|
-
view.bindResetButtonClick(
|
|
4344
|
-
view.bindZoomInButtonClick(
|
|
4345
|
-
view.bindZoomOutButtonClick(
|
|
4346
|
-
view.bindDisableDragButtonClick(
|
|
4347
|
-
view.bindDeleteButtonClick(
|
|
4348
|
-
api.controlBar.onStateChanged.subscribe(
|
|
4380
|
+
view.bindResetButtonClick(bar.onResetButtonClicked);
|
|
4381
|
+
view.bindZoomInButtonClick(bar.onZoomInButtonClicked);
|
|
4382
|
+
view.bindZoomOutButtonClick(bar.onZoomOutButtonClicked);
|
|
4383
|
+
view.bindDisableDragButtonClick(bar.onMoveButtonClicked);
|
|
4384
|
+
view.bindDeleteButtonClick(bar.onDeleteButtonClicked);
|
|
4385
|
+
api.controlBar.onStateChanged.subscribe(bar.refreshButtons);
|
|
4349
4386
|
if (isUndoRedoSupported) {
|
|
4350
|
-
view.bindUndoButtonClick(
|
|
4351
|
-
view.bindRedoButtonClick(
|
|
4387
|
+
view.bindUndoButtonClick(bar.onUndoButtonClicked);
|
|
4388
|
+
view.bindRedoButtonClick(bar.onRedoButtonClicked);
|
|
4389
|
+
}
|
|
4390
|
+
if (customButtons) {
|
|
4391
|
+
view.bindCustomButtonClick(bar.onCustomButtonClicked);
|
|
4352
4392
|
}
|
|
4353
4393
|
bar.refreshButtons();
|
|
4354
4394
|
return bar;
|
|
@@ -4358,6 +4398,37 @@ class ControlBar {
|
|
|
4358
4398
|
this.controlBarApi = controlBarApi;
|
|
4359
4399
|
this.viewportApi = viewportApi;
|
|
4360
4400
|
this.isUndoRedoSupported = isUndoRedoSupported;
|
|
4401
|
+
this.onResetButtonClicked = () => {
|
|
4402
|
+
this.viewportApi.resetViewport();
|
|
4403
|
+
};
|
|
4404
|
+
this.onZoomInButtonClicked = () => {
|
|
4405
|
+
this.viewportApi.zoom(true);
|
|
4406
|
+
};
|
|
4407
|
+
this.onZoomOutButtonClicked = () => {
|
|
4408
|
+
this.viewportApi.zoom(false);
|
|
4409
|
+
};
|
|
4410
|
+
this.onMoveButtonClicked = () => {
|
|
4411
|
+
this.controlBarApi.toggleIsDragDisabled();
|
|
4412
|
+
};
|
|
4413
|
+
this.onUndoButtonClicked = () => {
|
|
4414
|
+
this.controlBarApi.tryUndo();
|
|
4415
|
+
};
|
|
4416
|
+
this.onRedoButtonClicked = () => {
|
|
4417
|
+
this.controlBarApi.tryRedo();
|
|
4418
|
+
};
|
|
4419
|
+
this.onDeleteButtonClicked = () => {
|
|
4420
|
+
this.controlBarApi.tryDelete();
|
|
4421
|
+
};
|
|
4422
|
+
this.refreshButtons = () => {
|
|
4423
|
+
this.refreshDeleteButtonVisibility();
|
|
4424
|
+
this.refreshIsDragDisabled();
|
|
4425
|
+
if (this.isUndoRedoSupported) {
|
|
4426
|
+
this.refreshUndoRedoAvailability();
|
|
4427
|
+
}
|
|
4428
|
+
};
|
|
4429
|
+
this.onCustomButtonClicked = (id) => {
|
|
4430
|
+
this.controlBarApi.triggerButtonClick(id);
|
|
4431
|
+
};
|
|
4361
4432
|
}
|
|
4362
4433
|
updateLayout() {
|
|
4363
4434
|
//
|
|
@@ -4365,34 +4436,6 @@ class ControlBar {
|
|
|
4365
4436
|
destroy() {
|
|
4366
4437
|
//
|
|
4367
4438
|
}
|
|
4368
|
-
onResetButtonClicked() {
|
|
4369
|
-
this.viewportApi.resetViewport();
|
|
4370
|
-
}
|
|
4371
|
-
onZoomInButtonClicked() {
|
|
4372
|
-
this.viewportApi.zoom(true);
|
|
4373
|
-
}
|
|
4374
|
-
onZoomOutButtonClicked() {
|
|
4375
|
-
this.viewportApi.zoom(false);
|
|
4376
|
-
}
|
|
4377
|
-
onMoveButtonClicked() {
|
|
4378
|
-
this.controlBarApi.toggleIsDragDisabled();
|
|
4379
|
-
}
|
|
4380
|
-
onUndoButtonClicked() {
|
|
4381
|
-
this.controlBarApi.tryUndo();
|
|
4382
|
-
}
|
|
4383
|
-
onRedoButtonClicked() {
|
|
4384
|
-
this.controlBarApi.tryRedo();
|
|
4385
|
-
}
|
|
4386
|
-
onDeleteButtonClicked() {
|
|
4387
|
-
this.controlBarApi.tryDelete();
|
|
4388
|
-
}
|
|
4389
|
-
refreshButtons() {
|
|
4390
|
-
this.refreshDeleteButtonVisibility();
|
|
4391
|
-
this.refreshIsDragDisabled();
|
|
4392
|
-
if (this.isUndoRedoSupported) {
|
|
4393
|
-
this.refreshUndoRedoAvailability();
|
|
4394
|
-
}
|
|
4395
|
-
}
|
|
4396
4439
|
//
|
|
4397
4440
|
refreshIsDragDisabled() {
|
|
4398
4441
|
const isDragDisabled = this.controlBarApi.isDragDisabled();
|
|
@@ -5067,8 +5110,8 @@ class Designer {
|
|
|
5067
5110
|
/**
|
|
5068
5111
|
* Creates a designer.
|
|
5069
5112
|
* @param placeholder Placeholder where the designer will be attached.
|
|
5070
|
-
* @param startDefinition
|
|
5071
|
-
* @param configuration
|
|
5113
|
+
* @param startDefinition Initial definition of the workflow.
|
|
5114
|
+
* @param configuration The designer configuration.
|
|
5072
5115
|
* @returns An instance of the designer.
|
|
5073
5116
|
*/
|
|
5074
5117
|
static create(placeholder, startDefinition, configuration) {
|
|
@@ -5155,37 +5198,37 @@ class Designer {
|
|
|
5155
5198
|
this.onPreferencesChanged = new SimpleEvent();
|
|
5156
5199
|
}
|
|
5157
5200
|
/**
|
|
5158
|
-
* @returns
|
|
5201
|
+
* @returns The current definition of the workflow.
|
|
5159
5202
|
*/
|
|
5160
5203
|
getDefinition() {
|
|
5161
5204
|
return this.state.definition;
|
|
5162
5205
|
}
|
|
5163
5206
|
/**
|
|
5164
|
-
* @returns
|
|
5207
|
+
* @returns The validation result of the current definition.
|
|
5165
5208
|
*/
|
|
5166
5209
|
isValid() {
|
|
5167
5210
|
return this.view.workspace.isValid;
|
|
5168
5211
|
}
|
|
5169
5212
|
/**
|
|
5170
|
-
* @returns
|
|
5213
|
+
* @returns The read-only flag.
|
|
5171
5214
|
*/
|
|
5172
5215
|
isReadonly() {
|
|
5173
5216
|
return this.state.isReadonly;
|
|
5174
5217
|
}
|
|
5175
5218
|
/**
|
|
5176
|
-
* @description Changes the
|
|
5219
|
+
* @description Changes the read-only flag.
|
|
5177
5220
|
*/
|
|
5178
5221
|
setIsReadonly(isReadonly) {
|
|
5179
5222
|
this.state.setIsReadonly(isReadonly);
|
|
5180
5223
|
}
|
|
5181
5224
|
/**
|
|
5182
|
-
* @returns
|
|
5225
|
+
* @returns The currently selected step id, or `null` if nothing is selected.
|
|
5183
5226
|
*/
|
|
5184
5227
|
getSelectedStepId() {
|
|
5185
5228
|
return this.state.selectedStepId;
|
|
5186
5229
|
}
|
|
5187
5230
|
/**
|
|
5188
|
-
* @description Selects a step by
|
|
5231
|
+
* @description Selects a step by id.
|
|
5189
5232
|
*/
|
|
5190
5233
|
selectStepById(stepId) {
|
|
5191
5234
|
this.state.setSelectedStepId(stepId);
|
|
@@ -5197,7 +5240,7 @@ class Designer {
|
|
|
5197
5240
|
this.state.setSelectedStepId(null);
|
|
5198
5241
|
}
|
|
5199
5242
|
/**
|
|
5200
|
-
* @returns
|
|
5243
|
+
* @returns The current viewport.
|
|
5201
5244
|
*/
|
|
5202
5245
|
getViewport() {
|
|
5203
5246
|
return this.state.viewport;
|
|
@@ -5216,13 +5259,13 @@ class Designer {
|
|
|
5216
5259
|
this.api.viewport.resetViewport();
|
|
5217
5260
|
}
|
|
5218
5261
|
/**
|
|
5219
|
-
* @description Moves the viewport to the step with
|
|
5262
|
+
* @description Moves the viewport to the step with animation.
|
|
5220
5263
|
*/
|
|
5221
5264
|
moveViewportToStep(stepId) {
|
|
5222
5265
|
this.api.viewport.moveViewportToStep(stepId);
|
|
5223
5266
|
}
|
|
5224
5267
|
/**
|
|
5225
|
-
* @description
|
|
5268
|
+
* @description Rerenders the root component and all its children.
|
|
5226
5269
|
*/
|
|
5227
5270
|
updateRootComponent() {
|
|
5228
5271
|
this.api.workspace.updateRootComponent();
|
|
@@ -5241,37 +5284,37 @@ class Designer {
|
|
|
5241
5284
|
this.api.workspace.updateBadges();
|
|
5242
5285
|
}
|
|
5243
5286
|
/**
|
|
5244
|
-
* @returns
|
|
5287
|
+
* @returns A flag that indicates whether the toolbox is collapsed.
|
|
5245
5288
|
*/
|
|
5246
5289
|
isToolboxCollapsed() {
|
|
5247
5290
|
return this.state.isToolboxCollapsed;
|
|
5248
5291
|
}
|
|
5249
5292
|
/**
|
|
5250
|
-
* @description Sets
|
|
5293
|
+
* @description Sets the flag that indicates whether the toolbox is collapsed.
|
|
5251
5294
|
*/
|
|
5252
5295
|
setIsToolboxCollapsed(isCollapsed) {
|
|
5253
5296
|
this.state.setIsToolboxCollapsed(isCollapsed);
|
|
5254
5297
|
}
|
|
5255
5298
|
/**
|
|
5256
|
-
* @returns
|
|
5299
|
+
* @returns A flag that indicates whether the editor is collapsed.
|
|
5257
5300
|
*/
|
|
5258
5301
|
isEditorCollapsed() {
|
|
5259
5302
|
return this.state.isEditorCollapsed;
|
|
5260
5303
|
}
|
|
5261
5304
|
/**
|
|
5262
|
-
* @returns
|
|
5305
|
+
* @returns A flag that indicates whether a step is being dragged.
|
|
5263
5306
|
*/
|
|
5264
5307
|
isDragging() {
|
|
5265
5308
|
return this.state.isDragging;
|
|
5266
5309
|
}
|
|
5267
5310
|
/**
|
|
5268
|
-
* @description Sets
|
|
5311
|
+
* @description Sets the flag that indicates whether the editor is collapsed.
|
|
5269
5312
|
*/
|
|
5270
5313
|
setIsEditorCollapsed(isCollapsed) {
|
|
5271
5314
|
this.state.setIsEditorCollapsed(isCollapsed);
|
|
5272
5315
|
}
|
|
5273
5316
|
/**
|
|
5274
|
-
* @description
|
|
5317
|
+
* @description Dumps the undo stack.
|
|
5275
5318
|
*/
|
|
5276
5319
|
dumpUndoStack() {
|
|
5277
5320
|
return this.getHistoryController().dump();
|
|
@@ -5291,13 +5334,13 @@ class Designer {
|
|
|
5291
5334
|
}
|
|
5292
5335
|
/**
|
|
5293
5336
|
* @param needle A step, a sequence or a step id.
|
|
5294
|
-
* @returns
|
|
5337
|
+
* @returns Parent steps and branch names.
|
|
5295
5338
|
*/
|
|
5296
5339
|
getStepParents(needle) {
|
|
5297
5340
|
return this.walker.getParents(this.state.definition, needle);
|
|
5298
5341
|
}
|
|
5299
5342
|
/**
|
|
5300
|
-
* @returns
|
|
5343
|
+
* @returns The definition walker.
|
|
5301
5344
|
*/
|
|
5302
5345
|
getWalker() {
|
|
5303
5346
|
return this.walker;
|