sequential-workflow-designer 0.24.4 → 0.24.6
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 +107 -73
- package/lib/cjs/index.cjs +107 -73
- package/lib/esm/index.js +107 -73
- package/lib/index.d.ts +19 -19
- package/package.json +1 -1
package/lib/esm/index.js
CHANGED
|
@@ -402,17 +402,19 @@ class PathBarApi {
|
|
|
402
402
|
|
|
403
403
|
class DragStepView {
|
|
404
404
|
static create(step, theme, componentContext) {
|
|
405
|
+
var _a;
|
|
406
|
+
const body = (_a = componentContext.shadowRoot) !== null && _a !== void 0 ? _a : document.body;
|
|
405
407
|
const layer = Dom.element('div', {
|
|
406
408
|
class: `sqd-drag sqd-theme-${theme}`
|
|
407
409
|
});
|
|
408
|
-
|
|
410
|
+
body.appendChild(layer);
|
|
409
411
|
const component = componentContext.services.draggedComponent.create(layer, step, componentContext);
|
|
410
|
-
return new DragStepView(component, layer,
|
|
412
|
+
return new DragStepView(component, layer, body);
|
|
411
413
|
}
|
|
412
|
-
constructor(component, layer,
|
|
414
|
+
constructor(component, layer, body) {
|
|
413
415
|
this.component = component;
|
|
414
416
|
this.layer = layer;
|
|
415
|
-
this.
|
|
417
|
+
this.body = body;
|
|
416
418
|
}
|
|
417
419
|
setPosition(position) {
|
|
418
420
|
this.layer.style.top = position.y + 'px';
|
|
@@ -420,7 +422,7 @@ class DragStepView {
|
|
|
420
422
|
}
|
|
421
423
|
remove() {
|
|
422
424
|
this.component.destroy();
|
|
423
|
-
this.
|
|
425
|
+
this.body.removeChild(this.layer);
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
|
|
@@ -725,11 +727,10 @@ class DesignerApi {
|
|
|
725
727
|
const viewportController = context.services.viewportController.create(workspace);
|
|
726
728
|
const viewport = new ViewportApi(context.workspaceController, viewportController);
|
|
727
729
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
728
|
-
return new DesignerApi(context.
|
|
730
|
+
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
729
731
|
}
|
|
730
|
-
constructor(
|
|
731
|
-
this.
|
|
732
|
-
this.documentBody = documentBody;
|
|
732
|
+
constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
|
|
733
|
+
this.shadowRoot = shadowRoot;
|
|
733
734
|
this.controlBar = controlBar;
|
|
734
735
|
this.toolbox = toolbox;
|
|
735
736
|
this.editor = editor;
|
|
@@ -968,15 +969,14 @@ class StepComponentFactory {
|
|
|
968
969
|
}
|
|
969
970
|
|
|
970
971
|
class ComponentContext {
|
|
971
|
-
static create(
|
|
972
|
+
static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
|
|
972
973
|
const validator = new DefinitionValidator(configuration.validator, state);
|
|
973
974
|
const iconProvider = new IconProvider(configuration.steps);
|
|
974
975
|
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
975
|
-
return new ComponentContext(
|
|
976
|
+
return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
|
|
976
977
|
}
|
|
977
|
-
constructor(
|
|
978
|
-
this.
|
|
979
|
-
this.documentBody = documentBody;
|
|
978
|
+
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
|
|
979
|
+
this.shadowRoot = shadowRoot;
|
|
980
980
|
this.validator = validator;
|
|
981
981
|
this.iconProvider = iconProvider;
|
|
982
982
|
this.placeholderController = placeholderController;
|
|
@@ -1703,6 +1703,12 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1703
1703
|
|
|
1704
1704
|
class CenteredViewportCalculator {
|
|
1705
1705
|
static center(margin, canvasSize, rootComponentSize) {
|
|
1706
|
+
if (canvasSize.x === 0 || canvasSize.y === 0) {
|
|
1707
|
+
return {
|
|
1708
|
+
position: new Vector(0, 0),
|
|
1709
|
+
scale: 1
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1706
1712
|
const canvasSafeWidth = Math.max(canvasSize.x - margin * 2, 0);
|
|
1707
1713
|
const canvasSafeHeight = Math.max(canvasSize.y - margin * 2, 0);
|
|
1708
1714
|
const scale = Math.min(Math.min(canvasSafeWidth / rootComponentSize.x, canvasSafeHeight / rootComponentSize.y), 1);
|
|
@@ -2051,32 +2057,41 @@ const nonPassiveOptions = {
|
|
|
2051
2057
|
passive: false
|
|
2052
2058
|
};
|
|
2053
2059
|
class BehaviorController {
|
|
2054
|
-
|
|
2055
|
-
|
|
2060
|
+
static create(shadowRoot) {
|
|
2061
|
+
return new BehaviorController(shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document, shadowRoot);
|
|
2062
|
+
}
|
|
2063
|
+
constructor(dom, shadowRoot) {
|
|
2064
|
+
this.dom = dom;
|
|
2065
|
+
this.shadowRoot = shadowRoot;
|
|
2056
2066
|
this.onMouseMove = (e) => {
|
|
2057
2067
|
e.preventDefault();
|
|
2068
|
+
e.stopPropagation();
|
|
2058
2069
|
this.move(readMousePosition(e));
|
|
2059
2070
|
};
|
|
2060
2071
|
this.onTouchMove = (e) => {
|
|
2061
2072
|
e.preventDefault();
|
|
2073
|
+
e.stopPropagation();
|
|
2062
2074
|
this.move(readTouchPosition(e));
|
|
2063
2075
|
};
|
|
2064
2076
|
this.onMouseUp = (e) => {
|
|
2065
2077
|
e.preventDefault();
|
|
2078
|
+
e.stopPropagation();
|
|
2066
2079
|
this.stop(false, e.target);
|
|
2067
2080
|
};
|
|
2068
2081
|
this.onTouchEnd = (e) => {
|
|
2069
2082
|
var _a;
|
|
2070
2083
|
e.preventDefault();
|
|
2084
|
+
e.stopPropagation();
|
|
2071
2085
|
if (!this.state) {
|
|
2072
2086
|
throw new Error(notInitializedError);
|
|
2073
2087
|
}
|
|
2074
2088
|
const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
|
|
2075
|
-
const element = this.
|
|
2089
|
+
const element = this.dom.elementFromPoint(position.x, position.y);
|
|
2076
2090
|
this.stop(false, element);
|
|
2077
2091
|
};
|
|
2078
2092
|
this.onTouchStart = (e) => {
|
|
2079
2093
|
e.preventDefault();
|
|
2094
|
+
e.stopPropagation();
|
|
2080
2095
|
if (e.touches.length !== 1) {
|
|
2081
2096
|
this.stop(true, null);
|
|
2082
2097
|
}
|
|
@@ -2092,11 +2107,24 @@ class BehaviorController {
|
|
|
2092
2107
|
behavior
|
|
2093
2108
|
};
|
|
2094
2109
|
behavior.onStart(this.state.startPosition);
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2110
|
+
if (this.shadowRoot) {
|
|
2111
|
+
this.bind(this.shadowRoot);
|
|
2112
|
+
}
|
|
2113
|
+
this.bind(window);
|
|
2114
|
+
}
|
|
2115
|
+
bind(target) {
|
|
2116
|
+
target.addEventListener('mousemove', this.onMouseMove, false);
|
|
2117
|
+
target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
|
|
2118
|
+
target.addEventListener('mouseup', this.onMouseUp, false);
|
|
2119
|
+
target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
|
|
2120
|
+
target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
|
|
2121
|
+
}
|
|
2122
|
+
unbind(target) {
|
|
2123
|
+
target.removeEventListener('mousemove', this.onMouseMove, false);
|
|
2124
|
+
target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
|
|
2125
|
+
target.removeEventListener('mouseup', this.onMouseUp, false);
|
|
2126
|
+
target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
|
|
2127
|
+
target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
|
|
2100
2128
|
}
|
|
2101
2129
|
move(position) {
|
|
2102
2130
|
if (!this.state) {
|
|
@@ -2116,11 +2144,10 @@ class BehaviorController {
|
|
|
2116
2144
|
if (!this.state) {
|
|
2117
2145
|
throw new Error(notInitializedError);
|
|
2118
2146
|
}
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
window.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
|
|
2147
|
+
if (this.shadowRoot) {
|
|
2148
|
+
this.unbind(this.shadowRoot);
|
|
2149
|
+
}
|
|
2150
|
+
this.unbind(window);
|
|
2124
2151
|
this.state.behavior.onEnd(interrupt, element);
|
|
2125
2152
|
this.state = undefined;
|
|
2126
2153
|
}
|
|
@@ -2483,11 +2510,11 @@ function areItemsEqual(item, changeType, stepId) {
|
|
|
2483
2510
|
}
|
|
2484
2511
|
|
|
2485
2512
|
class LayoutController {
|
|
2486
|
-
constructor(
|
|
2487
|
-
this.
|
|
2513
|
+
constructor(placeholder) {
|
|
2514
|
+
this.placeholder = placeholder;
|
|
2488
2515
|
}
|
|
2489
2516
|
isMobile() {
|
|
2490
|
-
return this.
|
|
2517
|
+
return this.placeholder.clientWidth < 400; // TODO
|
|
2491
2518
|
}
|
|
2492
2519
|
}
|
|
2493
2520
|
|
|
@@ -2544,18 +2571,18 @@ class MemoryPreferenceStorage {
|
|
|
2544
2571
|
}
|
|
2545
2572
|
|
|
2546
2573
|
class DesignerContext {
|
|
2547
|
-
static create(
|
|
2574
|
+
static create(placeholder, startDefinition, configuration, services) {
|
|
2548
2575
|
var _a, _b, _c, _d, _e;
|
|
2549
2576
|
const definition = ObjectCloner.deepClone(startDefinition);
|
|
2550
|
-
const layoutController = new LayoutController(
|
|
2551
|
-
const isReadonly =
|
|
2577
|
+
const layoutController = new LayoutController(placeholder);
|
|
2578
|
+
const isReadonly = Boolean(configuration.isReadonly);
|
|
2552
2579
|
const isToolboxCollapsed = configuration.toolbox ? (_a = configuration.toolbox.isCollapsed) !== null && _a !== void 0 ? _a : layoutController.isMobile() : false;
|
|
2553
2580
|
const isEditorCollapsed = configuration.editors ? (_b = configuration.editors.isCollapsed) !== null && _b !== void 0 ? _b : layoutController.isMobile() : false;
|
|
2554
2581
|
const theme = configuration.theme || 'light';
|
|
2555
2582
|
const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
|
|
2556
2583
|
const workspaceController = new WorkspaceControllerWrapper();
|
|
2557
2584
|
const placeholderController = services.placeholderController.create();
|
|
2558
|
-
const behaviorController =
|
|
2585
|
+
const behaviorController = BehaviorController.create(configuration.shadowRoot);
|
|
2559
2586
|
const stepExtensionResolver = StepExtensionResolver.create(services);
|
|
2560
2587
|
const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
|
|
2561
2588
|
const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
|
|
@@ -2566,12 +2593,10 @@ class DesignerContext {
|
|
|
2566
2593
|
historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
|
|
2567
2594
|
}
|
|
2568
2595
|
const preferenceStorage = (_e = configuration.preferenceStorage) !== null && _e !== void 0 ? _e : new MemoryPreferenceStorage();
|
|
2569
|
-
const componentContext = ComponentContext.create(
|
|
2570
|
-
return new DesignerContext(
|
|
2596
|
+
const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services);
|
|
2597
|
+
return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
|
|
2571
2598
|
}
|
|
2572
|
-
constructor(
|
|
2573
|
-
this.documentOrShadowRoot = documentOrShadowRoot;
|
|
2574
|
-
this.documentBody = documentBody;
|
|
2599
|
+
constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
|
|
2575
2600
|
this.theme = theme;
|
|
2576
2601
|
this.state = state;
|
|
2577
2602
|
this.configuration = configuration;
|
|
@@ -2617,8 +2642,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
2617
2642
|
});
|
|
2618
2643
|
}
|
|
2619
2644
|
|
|
2620
|
-
function isElementAttached(
|
|
2621
|
-
return !(
|
|
2645
|
+
function isElementAttached(dom, element) {
|
|
2646
|
+
return !(dom.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
|
|
2622
2647
|
}
|
|
2623
2648
|
|
|
2624
2649
|
let lastGridPatternId = 0;
|
|
@@ -2652,12 +2677,12 @@ class WorkspaceView {
|
|
|
2652
2677
|
canvas.appendChild(foreground);
|
|
2653
2678
|
workspace.appendChild(canvas);
|
|
2654
2679
|
parent.appendChild(workspace);
|
|
2655
|
-
const view = new WorkspaceView(componentContext.
|
|
2680
|
+
const view = new WorkspaceView(componentContext.shadowRoot, workspace, canvas, pattern, gridPattern, foreground, componentContext);
|
|
2656
2681
|
window.addEventListener('resize', view.onResizeHandler, false);
|
|
2657
2682
|
return view;
|
|
2658
2683
|
}
|
|
2659
|
-
constructor(
|
|
2660
|
-
this.
|
|
2684
|
+
constructor(shadowRoot, workspace, canvas, pattern, gridPattern, foreground, context) {
|
|
2685
|
+
this.shadowRoot = shadowRoot;
|
|
2661
2686
|
this.workspace = workspace;
|
|
2662
2687
|
this.canvas = canvas;
|
|
2663
2688
|
this.pattern = pattern;
|
|
@@ -2698,9 +2723,11 @@ class WorkspaceView {
|
|
|
2698
2723
|
handler(readMousePosition(e), e.target, e.button, e.altKey);
|
|
2699
2724
|
}, false);
|
|
2700
2725
|
this.canvas.addEventListener('touchstart', e => {
|
|
2726
|
+
var _a;
|
|
2701
2727
|
e.preventDefault();
|
|
2702
2728
|
const clientPosition = readTouchClientPosition(e);
|
|
2703
|
-
const
|
|
2729
|
+
const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
|
|
2730
|
+
const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
|
|
2704
2731
|
if (element) {
|
|
2705
2732
|
const position = readTouchPosition(e);
|
|
2706
2733
|
handler(position, element, 0, false);
|
|
@@ -2883,7 +2910,7 @@ function findValidationBadgeIndex(extensions) {
|
|
|
2883
2910
|
}
|
|
2884
2911
|
|
|
2885
2912
|
class ContextMenu {
|
|
2886
|
-
static create(
|
|
2913
|
+
static create(shadowRoot, position, theme, items) {
|
|
2887
2914
|
const menu = document.createElement('div');
|
|
2888
2915
|
menu.style.left = `${position.x}px`;
|
|
2889
2916
|
menu.style.top = `${position.y}px`;
|
|
@@ -2903,16 +2930,19 @@ class ContextMenu {
|
|
|
2903
2930
|
elements.push(element);
|
|
2904
2931
|
menu.appendChild(element);
|
|
2905
2932
|
}
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2933
|
+
const body = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document.body;
|
|
2934
|
+
const dom = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document;
|
|
2935
|
+
const instance = new ContextMenu(body, dom, menu, elements, items, Date.now());
|
|
2936
|
+
dom.addEventListener('mousedown', instance.mouseDown, false);
|
|
2937
|
+
dom.addEventListener('mouseup', instance.mouseUp, false);
|
|
2938
|
+
dom.addEventListener('touchstart', instance.mouseDown, false);
|
|
2939
|
+
dom.addEventListener('touchend', instance.mouseUp, false);
|
|
2940
|
+
body.appendChild(menu);
|
|
2912
2941
|
return instance;
|
|
2913
2942
|
}
|
|
2914
|
-
constructor(
|
|
2915
|
-
this.
|
|
2943
|
+
constructor(body, dom, menu, elements, items, startTime) {
|
|
2944
|
+
this.body = body;
|
|
2945
|
+
this.dom = dom;
|
|
2916
2946
|
this.menu = menu;
|
|
2917
2947
|
this.elements = elements;
|
|
2918
2948
|
this.items = items;
|
|
@@ -2959,19 +2989,18 @@ class ContextMenu {
|
|
|
2959
2989
|
}
|
|
2960
2990
|
tryDestroy() {
|
|
2961
2991
|
if (this.isAttached) {
|
|
2962
|
-
this.
|
|
2963
|
-
this.
|
|
2964
|
-
this.
|
|
2965
|
-
this.
|
|
2966
|
-
this.
|
|
2992
|
+
this.body.removeChild(this.menu);
|
|
2993
|
+
this.dom.removeEventListener('mousedown', this.mouseDown, false);
|
|
2994
|
+
this.dom.removeEventListener('mouseup', this.mouseUp, false);
|
|
2995
|
+
this.dom.removeEventListener('touchstart', this.mouseDown, false);
|
|
2996
|
+
this.dom.removeEventListener('touchend', this.mouseUp, false);
|
|
2967
2997
|
this.isAttached = false;
|
|
2968
2998
|
}
|
|
2969
2999
|
}
|
|
2970
3000
|
}
|
|
2971
3001
|
|
|
2972
3002
|
class ContextMenuController {
|
|
2973
|
-
constructor(
|
|
2974
|
-
this.documentBody = documentBody;
|
|
3003
|
+
constructor(theme, configuration, itemsBuilder) {
|
|
2975
3004
|
this.theme = theme;
|
|
2976
3005
|
this.configuration = configuration;
|
|
2977
3006
|
this.itemsBuilder = itemsBuilder;
|
|
@@ -2985,7 +3014,7 @@ class ContextMenuController {
|
|
|
2985
3014
|
this.current.tryDestroy();
|
|
2986
3015
|
}
|
|
2987
3016
|
const items = this.itemsBuilder.build(commandOrNull);
|
|
2988
|
-
this.current = ContextMenu.create(this.
|
|
3017
|
+
this.current = ContextMenu.create(this.configuration.shadowRoot, position, this.theme, items);
|
|
2989
3018
|
}
|
|
2990
3019
|
destroy() {
|
|
2991
3020
|
if (this.current) {
|
|
@@ -3087,7 +3116,7 @@ class Workspace {
|
|
|
3087
3116
|
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3088
3117
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3089
3118
|
: undefined);
|
|
3090
|
-
const contextMenuController = new ContextMenuController(designerContext.
|
|
3119
|
+
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
3091
3120
|
const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
|
|
3092
3121
|
setTimeout(() => {
|
|
3093
3122
|
workspace.updateRootComponent();
|
|
@@ -3518,12 +3547,13 @@ class ControlBarExtension {
|
|
|
3518
3547
|
const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
3519
3548
|
class KeyboardDaemon {
|
|
3520
3549
|
static create(api, configuration) {
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3550
|
+
const dom = api.shadowRoot || document;
|
|
3551
|
+
const controller = new KeyboardDaemon(dom, api.controlBar, configuration);
|
|
3552
|
+
dom.addEventListener('keyup', controller.onKeyUp, false);
|
|
3523
3553
|
return controller;
|
|
3524
3554
|
}
|
|
3525
|
-
constructor(
|
|
3526
|
-
this.
|
|
3555
|
+
constructor(dom, controlBarApi, configuration) {
|
|
3556
|
+
this.dom = dom;
|
|
3527
3557
|
this.controlBarApi = controlBarApi;
|
|
3528
3558
|
this.configuration = configuration;
|
|
3529
3559
|
this.onKeyUp = (e) => {
|
|
@@ -3547,7 +3577,7 @@ class KeyboardDaemon {
|
|
|
3547
3577
|
};
|
|
3548
3578
|
}
|
|
3549
3579
|
destroy() {
|
|
3550
|
-
this.
|
|
3580
|
+
this.dom.removeEventListener('keyup', this.onKeyUp, false);
|
|
3551
3581
|
}
|
|
3552
3582
|
}
|
|
3553
3583
|
function detectAction(e) {
|
|
@@ -4395,7 +4425,7 @@ class Designer {
|
|
|
4395
4425
|
* @returns An instance of the designer.
|
|
4396
4426
|
*/
|
|
4397
4427
|
static create(placeholder, startDefinition, configuration) {
|
|
4398
|
-
var _a
|
|
4428
|
+
var _a;
|
|
4399
4429
|
if (!placeholder) {
|
|
4400
4430
|
throw new Error('Placeholder is not defined');
|
|
4401
4431
|
}
|
|
@@ -4404,13 +4434,11 @@ class Designer {
|
|
|
4404
4434
|
}
|
|
4405
4435
|
const config = configuration;
|
|
4406
4436
|
validateConfiguration(config);
|
|
4407
|
-
|
|
4408
|
-
const documentBody = (_b = configuration.documentBody) !== null && _b !== void 0 ? _b : document.body;
|
|
4409
|
-
if (!isElementAttached(placeholder, documentBody)) {
|
|
4437
|
+
if (!isElementAttached((_a = config.shadowRoot) !== null && _a !== void 0 ? _a : document, placeholder)) {
|
|
4410
4438
|
throw new Error('Placeholder is not attached to the DOM');
|
|
4411
4439
|
}
|
|
4412
4440
|
const services = ServicesResolver.resolve(configuration.extensions, config);
|
|
4413
|
-
const designerContext = DesignerContext.create(
|
|
4441
|
+
const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
|
|
4414
4442
|
const designerApi = DesignerApi.create(designerContext);
|
|
4415
4443
|
const view = DesignerView.create(placeholder, designerContext, designerApi);
|
|
4416
4444
|
const designer = new Designer(view, designerContext.state, designerContext.stateModifier, designerContext.definitionWalker, designerContext.historyController, designerApi);
|
|
@@ -4509,6 +4537,12 @@ class Designer {
|
|
|
4509
4537
|
setViewport(viewport) {
|
|
4510
4538
|
this.state.setViewport(viewport);
|
|
4511
4539
|
}
|
|
4540
|
+
/**
|
|
4541
|
+
* @description Resets the viewport.
|
|
4542
|
+
*/
|
|
4543
|
+
resetViewport() {
|
|
4544
|
+
this.api.viewport.resetViewport();
|
|
4545
|
+
}
|
|
4512
4546
|
/**
|
|
4513
4547
|
* @description Unselects the selected step.
|
|
4514
4548
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -75,10 +75,14 @@ interface Behavior {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
declare class BehaviorController {
|
|
78
|
-
private readonly
|
|
78
|
+
private readonly dom;
|
|
79
|
+
private readonly shadowRoot;
|
|
79
80
|
private state?;
|
|
80
|
-
|
|
81
|
+
static create(shadowRoot: ShadowRoot | undefined): BehaviorController;
|
|
82
|
+
private constructor();
|
|
81
83
|
start(startPosition: Vector, behavior: Behavior): void;
|
|
84
|
+
private bind;
|
|
85
|
+
private unbind;
|
|
82
86
|
private readonly onMouseMove;
|
|
83
87
|
private readonly onTouchMove;
|
|
84
88
|
private readonly onMouseUp;
|
|
@@ -273,8 +277,7 @@ declare class StepComponentFactory {
|
|
|
273
277
|
}
|
|
274
278
|
|
|
275
279
|
declare class ComponentContext {
|
|
276
|
-
readonly
|
|
277
|
-
readonly documentBody: Node;
|
|
280
|
+
readonly shadowRoot: ShadowRoot | undefined;
|
|
278
281
|
readonly validator: DefinitionValidator;
|
|
279
282
|
readonly iconProvider: IconProvider;
|
|
280
283
|
readonly placeholderController: PlaceholderController;
|
|
@@ -283,7 +286,7 @@ declare class ComponentContext {
|
|
|
283
286
|
readonly services: Services;
|
|
284
287
|
readonly preferenceStorage: PreferenceStorage;
|
|
285
288
|
readonly i18n: I18n;
|
|
286
|
-
static create(
|
|
289
|
+
static create(configuration: DesignerConfiguration, state: DesignerState, stepExtensionResolver: StepExtensionResolver, definitionWalker: DefinitionWalker, preferenceStorage: PreferenceStorage, placeholderController: PlaceholderController, i18n: I18n, services: Services): ComponentContext;
|
|
287
290
|
private constructor();
|
|
288
291
|
}
|
|
289
292
|
|
|
@@ -316,8 +319,8 @@ declare class HistoryController {
|
|
|
316
319
|
}
|
|
317
320
|
|
|
318
321
|
declare class LayoutController {
|
|
319
|
-
private readonly
|
|
320
|
-
constructor(
|
|
322
|
+
private readonly placeholder;
|
|
323
|
+
constructor(placeholder: HTMLElement);
|
|
321
324
|
isMobile(): boolean;
|
|
322
325
|
}
|
|
323
326
|
|
|
@@ -346,8 +349,6 @@ declare class WorkspaceControllerWrapper implements WorkspaceController {
|
|
|
346
349
|
}
|
|
347
350
|
|
|
348
351
|
declare class DesignerContext {
|
|
349
|
-
readonly documentOrShadowRoot: Document | ShadowRoot;
|
|
350
|
-
readonly documentBody: Node;
|
|
351
352
|
readonly theme: string;
|
|
352
353
|
readonly state: DesignerState;
|
|
353
354
|
readonly configuration: DesignerConfiguration;
|
|
@@ -362,8 +363,8 @@ declare class DesignerContext {
|
|
|
362
363
|
readonly behaviorController: BehaviorController;
|
|
363
364
|
readonly customActionController: CustomActionController;
|
|
364
365
|
readonly historyController: HistoryController | undefined;
|
|
365
|
-
static create(
|
|
366
|
-
constructor(
|
|
366
|
+
static create(placeholder: HTMLElement, startDefinition: Definition, configuration: DesignerConfiguration, services: Services): DesignerContext;
|
|
367
|
+
constructor(theme: string, state: DesignerState, configuration: DesignerConfiguration, services: Services, componentContext: ComponentContext, definitionWalker: DefinitionWalker, i18n: I18n, stateModifier: StateModifier, layoutController: LayoutController, workspaceController: WorkspaceControllerWrapper, placeholderController: PlaceholderController, behaviorController: BehaviorController, customActionController: CustomActionController, historyController: HistoryController | undefined);
|
|
367
368
|
setWorkspaceController(controller: WorkspaceController): void;
|
|
368
369
|
}
|
|
369
370
|
|
|
@@ -483,8 +484,7 @@ declare class WorkspaceApi {
|
|
|
483
484
|
}
|
|
484
485
|
|
|
485
486
|
declare class DesignerApi {
|
|
486
|
-
readonly
|
|
487
|
-
readonly documentBody: Node;
|
|
487
|
+
readonly shadowRoot: ShadowRoot | undefined;
|
|
488
488
|
readonly controlBar: ControlBarApi;
|
|
489
489
|
readonly toolbox: ToolboxApi;
|
|
490
490
|
readonly editor: EditorApi;
|
|
@@ -944,13 +944,9 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
|
|
|
944
944
|
*/
|
|
945
945
|
i18n?: I18n;
|
|
946
946
|
/**
|
|
947
|
-
* @description
|
|
948
|
-
*/
|
|
949
|
-
documentOrShadowRoot?: Document | ShadowRoot;
|
|
950
|
-
/**
|
|
951
|
-
* @description The body of the document. By default, the designer will use the `document.body`.
|
|
947
|
+
* @description Pass the shadow root of the shadow root to the designer if the designer is placed inside the shadow DOM.
|
|
952
948
|
*/
|
|
953
|
-
|
|
949
|
+
shadowRoot?: ShadowRoot;
|
|
954
950
|
}
|
|
955
951
|
type UidGenerator = () => string;
|
|
956
952
|
type I18n = (key: string, defaultValue: string) => string;
|
|
@@ -1189,6 +1185,10 @@ declare class Designer<TDefinition extends Definition = Definition> {
|
|
|
1189
1185
|
* @param viewport Viewport.
|
|
1190
1186
|
*/
|
|
1191
1187
|
setViewport(viewport: Viewport): void;
|
|
1188
|
+
/**
|
|
1189
|
+
* @description Resets the viewport.
|
|
1190
|
+
*/
|
|
1191
|
+
resetViewport(): void;
|
|
1192
1192
|
/**
|
|
1193
1193
|
* @description Unselects the selected step.
|
|
1194
1194
|
*/
|
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.24.
|
|
4
|
+
"version": "0.24.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|