sequential-workflow-designer 0.24.3 → 0.24.5

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 CHANGED
@@ -103,10 +103,10 @@ Add the below code to your head section in HTML document.
103
103
  ```html
104
104
  <head>
105
105
  ...
106
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.3/css/designer.css" rel="stylesheet">
107
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.3/css/designer-light.css" rel="stylesheet">
108
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.3/css/designer-dark.css" rel="stylesheet">
109
- <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.3/dist/index.umd.js"></script>
106
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.5/css/designer.css" rel="stylesheet">
107
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.5/css/designer-light.css" rel="stylesheet">
108
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.5/css/designer-dark.css" rel="stylesheet">
109
+ <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.5/dist/index.umd.js"></script>
110
110
  ```
111
111
 
112
112
  Call the designer by:
package/dist/index.umd.js CHANGED
@@ -405,17 +405,19 @@
405
405
 
406
406
  class DragStepView {
407
407
  static create(step, theme, componentContext) {
408
+ var _a;
409
+ const body = (_a = componentContext.shadowRoot) !== null && _a !== void 0 ? _a : document.body;
408
410
  const layer = Dom.element('div', {
409
411
  class: `sqd-drag sqd-theme-${theme}`
410
412
  });
411
- componentContext.documentBody.appendChild(layer);
413
+ body.appendChild(layer);
412
414
  const component = componentContext.services.draggedComponent.create(layer, step, componentContext);
413
- return new DragStepView(component, layer, componentContext.documentBody);
415
+ return new DragStepView(component, layer, body);
414
416
  }
415
- constructor(component, layer, documentBody) {
417
+ constructor(component, layer, body) {
416
418
  this.component = component;
417
419
  this.layer = layer;
418
- this.documentBody = documentBody;
420
+ this.body = body;
419
421
  }
420
422
  setPosition(position) {
421
423
  this.layer.style.top = position.y + 'px';
@@ -423,7 +425,7 @@
423
425
  }
424
426
  remove() {
425
427
  this.component.destroy();
426
- this.documentBody.removeChild(this.layer);
428
+ this.body.removeChild(this.layer);
427
429
  }
428
430
  }
429
431
 
@@ -728,9 +730,10 @@
728
730
  const viewportController = context.services.viewportController.create(workspace);
729
731
  const viewport = new ViewportApi(context.workspaceController, viewportController);
730
732
  const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
731
- return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
733
+ 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);
732
734
  }
733
- constructor(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
735
+ constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
736
+ this.shadowRoot = shadowRoot;
734
737
  this.controlBar = controlBar;
735
738
  this.toolbox = toolbox;
736
739
  this.editor = editor;
@@ -969,13 +972,14 @@
969
972
  }
970
973
 
971
974
  class ComponentContext {
972
- static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services, documentBody) {
975
+ static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
973
976
  const validator = new DefinitionValidator(configuration.validator, state);
974
977
  const iconProvider = new IconProvider(configuration.steps);
975
978
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
976
- return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, documentBody);
979
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
977
980
  }
978
- constructor(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, documentBody) {
981
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
982
+ this.shadowRoot = shadowRoot;
979
983
  this.validator = validator;
980
984
  this.iconProvider = iconProvider;
981
985
  this.placeholderController = placeholderController;
@@ -984,7 +988,6 @@
984
988
  this.services = services;
985
989
  this.preferenceStorage = preferenceStorage;
986
990
  this.i18n = i18n;
987
- this.documentBody = documentBody;
988
991
  }
989
992
  }
990
993
 
@@ -2234,31 +2237,41 @@
2234
2237
  passive: false
2235
2238
  };
2236
2239
  class BehaviorController {
2237
- constructor() {
2240
+ static create(shadowRoot) {
2241
+ return new BehaviorController(shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document, shadowRoot);
2242
+ }
2243
+ constructor(dom, shadowRoot) {
2244
+ this.dom = dom;
2245
+ this.shadowRoot = shadowRoot;
2238
2246
  this.onMouseMove = (e) => {
2239
2247
  e.preventDefault();
2248
+ e.stopPropagation();
2240
2249
  this.move(readMousePosition(e));
2241
2250
  };
2242
2251
  this.onTouchMove = (e) => {
2243
2252
  e.preventDefault();
2253
+ e.stopPropagation();
2244
2254
  this.move(readTouchPosition(e));
2245
2255
  };
2246
2256
  this.onMouseUp = (e) => {
2247
2257
  e.preventDefault();
2258
+ e.stopPropagation();
2248
2259
  this.stop(false, e.target);
2249
2260
  };
2250
2261
  this.onTouchEnd = (e) => {
2251
2262
  var _a;
2252
2263
  e.preventDefault();
2264
+ e.stopPropagation();
2253
2265
  if (!this.state) {
2254
2266
  throw new Error(notInitializedError);
2255
2267
  }
2256
2268
  const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
2257
- const element = document.elementFromPoint(position.x, position.y);
2269
+ const element = this.dom.elementFromPoint(position.x, position.y);
2258
2270
  this.stop(false, element);
2259
2271
  };
2260
2272
  this.onTouchStart = (e) => {
2261
2273
  e.preventDefault();
2274
+ e.stopPropagation();
2262
2275
  if (e.touches.length !== 1) {
2263
2276
  this.stop(true, null);
2264
2277
  }
@@ -2274,11 +2287,24 @@
2274
2287
  behavior
2275
2288
  };
2276
2289
  behavior.onStart(this.state.startPosition);
2277
- window.addEventListener('mousemove', this.onMouseMove, false);
2278
- window.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2279
- window.addEventListener('mouseup', this.onMouseUp, false);
2280
- window.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2281
- window.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2290
+ if (this.shadowRoot) {
2291
+ this.bind(this.shadowRoot);
2292
+ }
2293
+ this.bind(window);
2294
+ }
2295
+ bind(target) {
2296
+ target.addEventListener('mousemove', this.onMouseMove, false);
2297
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2298
+ target.addEventListener('mouseup', this.onMouseUp, false);
2299
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2300
+ target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2301
+ }
2302
+ unbind(target) {
2303
+ target.removeEventListener('mousemove', this.onMouseMove, false);
2304
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2305
+ target.removeEventListener('mouseup', this.onMouseUp, false);
2306
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2307
+ target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2282
2308
  }
2283
2309
  move(position) {
2284
2310
  if (!this.state) {
@@ -2298,11 +2324,10 @@
2298
2324
  if (!this.state) {
2299
2325
  throw new Error(notInitializedError);
2300
2326
  }
2301
- window.removeEventListener('mousemove', this.onMouseMove, false);
2302
- window.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2303
- window.removeEventListener('mouseup', this.onMouseUp, false);
2304
- window.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2305
- window.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2327
+ if (this.shadowRoot) {
2328
+ this.unbind(this.shadowRoot);
2329
+ }
2330
+ this.unbind(window);
2306
2331
  this.state.behavior.onEnd(interrupt, element);
2307
2332
  this.state = undefined;
2308
2333
  }
@@ -2665,11 +2690,11 @@
2665
2690
  }
2666
2691
 
2667
2692
  class LayoutController {
2668
- constructor(parent) {
2669
- this.parent = parent;
2693
+ constructor(placeholder) {
2694
+ this.placeholder = placeholder;
2670
2695
  }
2671
2696
  isMobile() {
2672
- return this.parent.clientWidth < 400; // TODO
2697
+ return this.placeholder.clientWidth < 400; // TODO
2673
2698
  }
2674
2699
  }
2675
2700
 
@@ -2726,18 +2751,18 @@
2726
2751
  }
2727
2752
 
2728
2753
  class DesignerContext {
2729
- static create(documentBody, parent, startDefinition, configuration, services) {
2754
+ static create(placeholder, startDefinition, configuration, services) {
2730
2755
  var _a, _b, _c, _d, _e;
2731
2756
  const definition = ObjectCloner.deepClone(startDefinition);
2732
- const layoutController = new LayoutController(parent);
2733
- const isReadonly = !!configuration.isReadonly;
2757
+ const layoutController = new LayoutController(placeholder);
2758
+ const isReadonly = Boolean(configuration.isReadonly);
2734
2759
  const isToolboxCollapsed = configuration.toolbox ? (_a = configuration.toolbox.isCollapsed) !== null && _a !== void 0 ? _a : layoutController.isMobile() : false;
2735
2760
  const isEditorCollapsed = configuration.editors ? (_b = configuration.editors.isCollapsed) !== null && _b !== void 0 ? _b : layoutController.isMobile() : false;
2736
2761
  const theme = configuration.theme || 'light';
2737
2762
  const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
2738
2763
  const workspaceController = new WorkspaceControllerWrapper();
2739
2764
  const placeholderController = services.placeholderController.create();
2740
- const behaviorController = new BehaviorController();
2765
+ const behaviorController = BehaviorController.create(configuration.shadowRoot);
2741
2766
  const stepExtensionResolver = StepExtensionResolver.create(services);
2742
2767
  const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
2743
2768
  const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
@@ -2748,11 +2773,10 @@
2748
2773
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
2749
2774
  }
2750
2775
  const preferenceStorage = (_e = configuration.preferenceStorage) !== null && _e !== void 0 ? _e : new MemoryPreferenceStorage();
2751
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services, documentBody);
2752
- return new DesignerContext(documentBody, theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
2776
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services);
2777
+ return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
2753
2778
  }
2754
- constructor(documentBody, theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
2755
- this.documentBody = documentBody;
2779
+ constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
2756
2780
  this.theme = theme;
2757
2781
  this.state = state;
2758
2782
  this.configuration = configuration;
@@ -2798,8 +2822,8 @@
2798
2822
  });
2799
2823
  }
2800
2824
 
2801
- function isElementAttached(element, documentBody) {
2802
- return !(documentBody.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2825
+ function isElementAttached(dom, element) {
2826
+ return !(dom.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2803
2827
  }
2804
2828
 
2805
2829
  let lastGridPatternId = 0;
@@ -2833,11 +2857,12 @@
2833
2857
  canvas.appendChild(foreground);
2834
2858
  workspace.appendChild(canvas);
2835
2859
  parent.appendChild(workspace);
2836
- const view = new WorkspaceView(workspace, canvas, pattern, gridPattern, foreground, componentContext);
2860
+ const view = new WorkspaceView(componentContext.shadowRoot, workspace, canvas, pattern, gridPattern, foreground, componentContext);
2837
2861
  window.addEventListener('resize', view.onResizeHandler, false);
2838
2862
  return view;
2839
2863
  }
2840
- constructor(workspace, canvas, pattern, gridPattern, foreground, context) {
2864
+ constructor(shadowRoot, workspace, canvas, pattern, gridPattern, foreground, context) {
2865
+ this.shadowRoot = shadowRoot;
2841
2866
  this.workspace = workspace;
2842
2867
  this.canvas = canvas;
2843
2868
  this.pattern = pattern;
@@ -2878,9 +2903,11 @@
2878
2903
  handler(readMousePosition(e), e.target, e.button, e.altKey);
2879
2904
  }, false);
2880
2905
  this.canvas.addEventListener('touchstart', e => {
2906
+ var _a;
2881
2907
  e.preventDefault();
2882
2908
  const clientPosition = readTouchClientPosition(e);
2883
- const element = document.elementFromPoint(clientPosition.x, clientPosition.y);
2909
+ const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
2910
+ const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
2884
2911
  if (element) {
2885
2912
  const position = readTouchPosition(e);
2886
2913
  handler(position, element, 0, false);
@@ -3063,7 +3090,7 @@
3063
3090
  }
3064
3091
 
3065
3092
  class ContextMenu {
3066
- static create(documentBody, position, theme, items) {
3093
+ static create(shadowRoot, position, theme, items) {
3067
3094
  const menu = document.createElement('div');
3068
3095
  menu.style.left = `${position.x}px`;
3069
3096
  menu.style.top = `${position.y}px`;
@@ -3083,16 +3110,19 @@
3083
3110
  elements.push(element);
3084
3111
  menu.appendChild(element);
3085
3112
  }
3086
- const instance = new ContextMenu(documentBody, menu, elements, items, Date.now());
3087
- document.addEventListener('mousedown', instance.mouseDown, false);
3088
- document.addEventListener('mouseup', instance.mouseUp, false);
3089
- document.addEventListener('touchstart', instance.mouseDown, false);
3090
- document.addEventListener('touchend', instance.mouseUp, false);
3091
- documentBody.appendChild(menu);
3113
+ const body = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document.body;
3114
+ const dom = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document;
3115
+ const instance = new ContextMenu(body, dom, menu, elements, items, Date.now());
3116
+ dom.addEventListener('mousedown', instance.mouseDown, false);
3117
+ dom.addEventListener('mouseup', instance.mouseUp, false);
3118
+ dom.addEventListener('touchstart', instance.mouseDown, false);
3119
+ dom.addEventListener('touchend', instance.mouseUp, false);
3120
+ body.appendChild(menu);
3092
3121
  return instance;
3093
3122
  }
3094
- constructor(documentBody, menu, elements, items, startTime) {
3095
- this.documentBody = documentBody;
3123
+ constructor(body, dom, menu, elements, items, startTime) {
3124
+ this.body = body;
3125
+ this.dom = dom;
3096
3126
  this.menu = menu;
3097
3127
  this.elements = elements;
3098
3128
  this.items = items;
@@ -3139,19 +3169,18 @@
3139
3169
  }
3140
3170
  tryDestroy() {
3141
3171
  if (this.isAttached) {
3142
- this.documentBody.removeChild(this.menu);
3143
- document.removeEventListener('mousedown', this.mouseDown, false);
3144
- document.removeEventListener('mouseup', this.mouseUp, false);
3145
- document.removeEventListener('touchstart', this.mouseDown, false);
3146
- document.removeEventListener('touchend', this.mouseUp, false);
3172
+ this.body.removeChild(this.menu);
3173
+ this.dom.removeEventListener('mousedown', this.mouseDown, false);
3174
+ this.dom.removeEventListener('mouseup', this.mouseUp, false);
3175
+ this.dom.removeEventListener('touchstart', this.mouseDown, false);
3176
+ this.dom.removeEventListener('touchend', this.mouseUp, false);
3147
3177
  this.isAttached = false;
3148
3178
  }
3149
3179
  }
3150
3180
  }
3151
3181
 
3152
3182
  class ContextMenuController {
3153
- constructor(documentBody, theme, configuration, itemsBuilder) {
3154
- this.documentBody = documentBody;
3183
+ constructor(theme, configuration, itemsBuilder) {
3155
3184
  this.theme = theme;
3156
3185
  this.configuration = configuration;
3157
3186
  this.itemsBuilder = itemsBuilder;
@@ -3165,7 +3194,7 @@
3165
3194
  this.current.tryDestroy();
3166
3195
  }
3167
3196
  const items = this.itemsBuilder.build(commandOrNull);
3168
- this.current = ContextMenu.create(this.documentBody, position, this.theme, items);
3197
+ this.current = ContextMenu.create(this.configuration.shadowRoot, position, this.theme, items);
3169
3198
  }
3170
3199
  destroy() {
3171
3200
  if (this.current) {
@@ -3267,7 +3296,7 @@
3267
3296
  const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3268
3297
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
3269
3298
  : undefined);
3270
- const contextMenuController = new ContextMenuController(designerContext.documentBody, designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3299
+ const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3271
3300
  const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
3272
3301
  setTimeout(() => {
3273
3302
  workspace.updateRootComponent();
@@ -3698,22 +3727,25 @@
3698
3727
  const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
3699
3728
  class KeyboardDaemon {
3700
3729
  static create(api, configuration) {
3701
- const controller = new KeyboardDaemon(api.controlBar, configuration);
3702
- document.addEventListener('keyup', controller.onKeyUp, false);
3730
+ const dom = api.shadowRoot || document;
3731
+ const controller = new KeyboardDaemon(dom, api.controlBar, configuration);
3732
+ dom.addEventListener('keyup', controller.onKeyUp, false);
3703
3733
  return controller;
3704
3734
  }
3705
- constructor(controlBarApi, configuration) {
3735
+ constructor(dom, controlBarApi, configuration) {
3736
+ this.dom = dom;
3706
3737
  this.controlBarApi = controlBarApi;
3707
3738
  this.configuration = configuration;
3708
3739
  this.onKeyUp = (e) => {
3709
- const action = detectAction(e);
3740
+ const ke = e;
3741
+ const action = detectAction(ke);
3710
3742
  if (!action) {
3711
3743
  return;
3712
3744
  }
3713
3745
  if (document.activeElement && ignoreTagNames.includes(document.activeElement.tagName)) {
3714
3746
  return;
3715
3747
  }
3716
- if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, e)) {
3748
+ if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, ke)) {
3717
3749
  return;
3718
3750
  }
3719
3751
  const isDeletable = this.controlBarApi.canDelete();
@@ -3725,7 +3757,7 @@
3725
3757
  };
3726
3758
  }
3727
3759
  destroy() {
3728
- document.removeEventListener('keyup', this.onKeyUp, false);
3760
+ this.dom.removeEventListener('keyup', this.onKeyUp, false);
3729
3761
  }
3730
3762
  }
3731
3763
  function detectAction(e) {
@@ -4582,12 +4614,11 @@
4582
4614
  }
4583
4615
  const config = configuration;
4584
4616
  validateConfiguration(config);
4585
- const documentBody = (_a = configuration.documentBody) !== null && _a !== void 0 ? _a : document.body;
4586
- if (!isElementAttached(placeholder, documentBody)) {
4617
+ if (!isElementAttached((_a = config.shadowRoot) !== null && _a !== void 0 ? _a : document, placeholder)) {
4587
4618
  throw new Error('Placeholder is not attached to the DOM');
4588
4619
  }
4589
4620
  const services = ServicesResolver.resolve(configuration.extensions, config);
4590
- const designerContext = DesignerContext.create(documentBody, placeholder, startDefinition, config, services);
4621
+ const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
4591
4622
  const designerApi = DesignerApi.create(designerContext);
4592
4623
  const view = DesignerView.create(placeholder, designerContext, designerApi);
4593
4624
  const designer = new Designer(view, designerContext.state, designerContext.stateModifier, designerContext.definitionWalker, designerContext.historyController, designerApi);
package/lib/cjs/index.cjs CHANGED
@@ -403,17 +403,19 @@ class PathBarApi {
403
403
 
404
404
  class DragStepView {
405
405
  static create(step, theme, componentContext) {
406
+ var _a;
407
+ const body = (_a = componentContext.shadowRoot) !== null && _a !== void 0 ? _a : document.body;
406
408
  const layer = Dom.element('div', {
407
409
  class: `sqd-drag sqd-theme-${theme}`
408
410
  });
409
- componentContext.documentBody.appendChild(layer);
411
+ body.appendChild(layer);
410
412
  const component = componentContext.services.draggedComponent.create(layer, step, componentContext);
411
- return new DragStepView(component, layer, componentContext.documentBody);
413
+ return new DragStepView(component, layer, body);
412
414
  }
413
- constructor(component, layer, documentBody) {
415
+ constructor(component, layer, body) {
414
416
  this.component = component;
415
417
  this.layer = layer;
416
- this.documentBody = documentBody;
418
+ this.body = body;
417
419
  }
418
420
  setPosition(position) {
419
421
  this.layer.style.top = position.y + 'px';
@@ -421,7 +423,7 @@ class DragStepView {
421
423
  }
422
424
  remove() {
423
425
  this.component.destroy();
424
- this.documentBody.removeChild(this.layer);
426
+ this.body.removeChild(this.layer);
425
427
  }
426
428
  }
427
429
 
@@ -726,9 +728,10 @@ class DesignerApi {
726
728
  const viewportController = context.services.viewportController.create(workspace);
727
729
  const viewport = new ViewportApi(context.workspaceController, viewportController);
728
730
  const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
729
- return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
731
+ 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);
730
732
  }
731
- constructor(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
733
+ constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
734
+ this.shadowRoot = shadowRoot;
732
735
  this.controlBar = controlBar;
733
736
  this.toolbox = toolbox;
734
737
  this.editor = editor;
@@ -967,13 +970,14 @@ class StepComponentFactory {
967
970
  }
968
971
 
969
972
  class ComponentContext {
970
- static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services, documentBody) {
973
+ static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
971
974
  const validator = new DefinitionValidator(configuration.validator, state);
972
975
  const iconProvider = new IconProvider(configuration.steps);
973
976
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
974
- return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, documentBody);
977
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
975
978
  }
976
- constructor(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, documentBody) {
979
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
980
+ this.shadowRoot = shadowRoot;
977
981
  this.validator = validator;
978
982
  this.iconProvider = iconProvider;
979
983
  this.placeholderController = placeholderController;
@@ -982,7 +986,6 @@ class ComponentContext {
982
986
  this.services = services;
983
987
  this.preferenceStorage = preferenceStorage;
984
988
  this.i18n = i18n;
985
- this.documentBody = documentBody;
986
989
  }
987
990
  }
988
991
 
@@ -2049,31 +2052,41 @@ const nonPassiveOptions = {
2049
2052
  passive: false
2050
2053
  };
2051
2054
  class BehaviorController {
2052
- constructor() {
2055
+ static create(shadowRoot) {
2056
+ return new BehaviorController(shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document, shadowRoot);
2057
+ }
2058
+ constructor(dom, shadowRoot) {
2059
+ this.dom = dom;
2060
+ this.shadowRoot = shadowRoot;
2053
2061
  this.onMouseMove = (e) => {
2054
2062
  e.preventDefault();
2063
+ e.stopPropagation();
2055
2064
  this.move(readMousePosition(e));
2056
2065
  };
2057
2066
  this.onTouchMove = (e) => {
2058
2067
  e.preventDefault();
2068
+ e.stopPropagation();
2059
2069
  this.move(readTouchPosition(e));
2060
2070
  };
2061
2071
  this.onMouseUp = (e) => {
2062
2072
  e.preventDefault();
2073
+ e.stopPropagation();
2063
2074
  this.stop(false, e.target);
2064
2075
  };
2065
2076
  this.onTouchEnd = (e) => {
2066
2077
  var _a;
2067
2078
  e.preventDefault();
2079
+ e.stopPropagation();
2068
2080
  if (!this.state) {
2069
2081
  throw new Error(notInitializedError);
2070
2082
  }
2071
2083
  const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
2072
- const element = document.elementFromPoint(position.x, position.y);
2084
+ const element = this.dom.elementFromPoint(position.x, position.y);
2073
2085
  this.stop(false, element);
2074
2086
  };
2075
2087
  this.onTouchStart = (e) => {
2076
2088
  e.preventDefault();
2089
+ e.stopPropagation();
2077
2090
  if (e.touches.length !== 1) {
2078
2091
  this.stop(true, null);
2079
2092
  }
@@ -2089,11 +2102,24 @@ class BehaviorController {
2089
2102
  behavior
2090
2103
  };
2091
2104
  behavior.onStart(this.state.startPosition);
2092
- window.addEventListener('mousemove', this.onMouseMove, false);
2093
- window.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2094
- window.addEventListener('mouseup', this.onMouseUp, false);
2095
- window.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2096
- window.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2105
+ if (this.shadowRoot) {
2106
+ this.bind(this.shadowRoot);
2107
+ }
2108
+ this.bind(window);
2109
+ }
2110
+ bind(target) {
2111
+ target.addEventListener('mousemove', this.onMouseMove, false);
2112
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2113
+ target.addEventListener('mouseup', this.onMouseUp, false);
2114
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2115
+ target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2116
+ }
2117
+ unbind(target) {
2118
+ target.removeEventListener('mousemove', this.onMouseMove, false);
2119
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2120
+ target.removeEventListener('mouseup', this.onMouseUp, false);
2121
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2122
+ target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2097
2123
  }
2098
2124
  move(position) {
2099
2125
  if (!this.state) {
@@ -2113,11 +2139,10 @@ class BehaviorController {
2113
2139
  if (!this.state) {
2114
2140
  throw new Error(notInitializedError);
2115
2141
  }
2116
- window.removeEventListener('mousemove', this.onMouseMove, false);
2117
- window.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2118
- window.removeEventListener('mouseup', this.onMouseUp, false);
2119
- window.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2120
- window.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2142
+ if (this.shadowRoot) {
2143
+ this.unbind(this.shadowRoot);
2144
+ }
2145
+ this.unbind(window);
2121
2146
  this.state.behavior.onEnd(interrupt, element);
2122
2147
  this.state = undefined;
2123
2148
  }
@@ -2480,11 +2505,11 @@ function areItemsEqual(item, changeType, stepId) {
2480
2505
  }
2481
2506
 
2482
2507
  class LayoutController {
2483
- constructor(parent) {
2484
- this.parent = parent;
2508
+ constructor(placeholder) {
2509
+ this.placeholder = placeholder;
2485
2510
  }
2486
2511
  isMobile() {
2487
- return this.parent.clientWidth < 400; // TODO
2512
+ return this.placeholder.clientWidth < 400; // TODO
2488
2513
  }
2489
2514
  }
2490
2515
 
@@ -2541,18 +2566,18 @@ class MemoryPreferenceStorage {
2541
2566
  }
2542
2567
 
2543
2568
  class DesignerContext {
2544
- static create(documentBody, parent, startDefinition, configuration, services) {
2569
+ static create(placeholder, startDefinition, configuration, services) {
2545
2570
  var _a, _b, _c, _d, _e;
2546
2571
  const definition = ObjectCloner.deepClone(startDefinition);
2547
- const layoutController = new LayoutController(parent);
2548
- const isReadonly = !!configuration.isReadonly;
2572
+ const layoutController = new LayoutController(placeholder);
2573
+ const isReadonly = Boolean(configuration.isReadonly);
2549
2574
  const isToolboxCollapsed = configuration.toolbox ? (_a = configuration.toolbox.isCollapsed) !== null && _a !== void 0 ? _a : layoutController.isMobile() : false;
2550
2575
  const isEditorCollapsed = configuration.editors ? (_b = configuration.editors.isCollapsed) !== null && _b !== void 0 ? _b : layoutController.isMobile() : false;
2551
2576
  const theme = configuration.theme || 'light';
2552
2577
  const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
2553
2578
  const workspaceController = new WorkspaceControllerWrapper();
2554
2579
  const placeholderController = services.placeholderController.create();
2555
- const behaviorController = new BehaviorController();
2580
+ const behaviorController = BehaviorController.create(configuration.shadowRoot);
2556
2581
  const stepExtensionResolver = StepExtensionResolver.create(services);
2557
2582
  const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new sequentialWorkflowModel.DefinitionWalker();
2558
2583
  const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
@@ -2563,11 +2588,10 @@ class DesignerContext {
2563
2588
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
2564
2589
  }
2565
2590
  const preferenceStorage = (_e = configuration.preferenceStorage) !== null && _e !== void 0 ? _e : new MemoryPreferenceStorage();
2566
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services, documentBody);
2567
- return new DesignerContext(documentBody, theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
2591
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services);
2592
+ return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
2568
2593
  }
2569
- constructor(documentBody, theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
2570
- this.documentBody = documentBody;
2594
+ constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
2571
2595
  this.theme = theme;
2572
2596
  this.state = state;
2573
2597
  this.configuration = configuration;
@@ -2613,8 +2637,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
2613
2637
  });
2614
2638
  }
2615
2639
 
2616
- function isElementAttached(element, documentBody) {
2617
- return !(documentBody.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2640
+ function isElementAttached(dom, element) {
2641
+ return !(dom.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2618
2642
  }
2619
2643
 
2620
2644
  let lastGridPatternId = 0;
@@ -2648,11 +2672,12 @@ class WorkspaceView {
2648
2672
  canvas.appendChild(foreground);
2649
2673
  workspace.appendChild(canvas);
2650
2674
  parent.appendChild(workspace);
2651
- const view = new WorkspaceView(workspace, canvas, pattern, gridPattern, foreground, componentContext);
2675
+ const view = new WorkspaceView(componentContext.shadowRoot, workspace, canvas, pattern, gridPattern, foreground, componentContext);
2652
2676
  window.addEventListener('resize', view.onResizeHandler, false);
2653
2677
  return view;
2654
2678
  }
2655
- constructor(workspace, canvas, pattern, gridPattern, foreground, context) {
2679
+ constructor(shadowRoot, workspace, canvas, pattern, gridPattern, foreground, context) {
2680
+ this.shadowRoot = shadowRoot;
2656
2681
  this.workspace = workspace;
2657
2682
  this.canvas = canvas;
2658
2683
  this.pattern = pattern;
@@ -2693,9 +2718,11 @@ class WorkspaceView {
2693
2718
  handler(readMousePosition(e), e.target, e.button, e.altKey);
2694
2719
  }, false);
2695
2720
  this.canvas.addEventListener('touchstart', e => {
2721
+ var _a;
2696
2722
  e.preventDefault();
2697
2723
  const clientPosition = readTouchClientPosition(e);
2698
- const element = document.elementFromPoint(clientPosition.x, clientPosition.y);
2724
+ const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
2725
+ const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
2699
2726
  if (element) {
2700
2727
  const position = readTouchPosition(e);
2701
2728
  handler(position, element, 0, false);
@@ -2878,7 +2905,7 @@ function findValidationBadgeIndex(extensions) {
2878
2905
  }
2879
2906
 
2880
2907
  class ContextMenu {
2881
- static create(documentBody, position, theme, items) {
2908
+ static create(shadowRoot, position, theme, items) {
2882
2909
  const menu = document.createElement('div');
2883
2910
  menu.style.left = `${position.x}px`;
2884
2911
  menu.style.top = `${position.y}px`;
@@ -2898,16 +2925,19 @@ class ContextMenu {
2898
2925
  elements.push(element);
2899
2926
  menu.appendChild(element);
2900
2927
  }
2901
- const instance = new ContextMenu(documentBody, menu, elements, items, Date.now());
2902
- document.addEventListener('mousedown', instance.mouseDown, false);
2903
- document.addEventListener('mouseup', instance.mouseUp, false);
2904
- document.addEventListener('touchstart', instance.mouseDown, false);
2905
- document.addEventListener('touchend', instance.mouseUp, false);
2906
- documentBody.appendChild(menu);
2928
+ const body = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document.body;
2929
+ const dom = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document;
2930
+ const instance = new ContextMenu(body, dom, menu, elements, items, Date.now());
2931
+ dom.addEventListener('mousedown', instance.mouseDown, false);
2932
+ dom.addEventListener('mouseup', instance.mouseUp, false);
2933
+ dom.addEventListener('touchstart', instance.mouseDown, false);
2934
+ dom.addEventListener('touchend', instance.mouseUp, false);
2935
+ body.appendChild(menu);
2907
2936
  return instance;
2908
2937
  }
2909
- constructor(documentBody, menu, elements, items, startTime) {
2910
- this.documentBody = documentBody;
2938
+ constructor(body, dom, menu, elements, items, startTime) {
2939
+ this.body = body;
2940
+ this.dom = dom;
2911
2941
  this.menu = menu;
2912
2942
  this.elements = elements;
2913
2943
  this.items = items;
@@ -2954,19 +2984,18 @@ class ContextMenu {
2954
2984
  }
2955
2985
  tryDestroy() {
2956
2986
  if (this.isAttached) {
2957
- this.documentBody.removeChild(this.menu);
2958
- document.removeEventListener('mousedown', this.mouseDown, false);
2959
- document.removeEventListener('mouseup', this.mouseUp, false);
2960
- document.removeEventListener('touchstart', this.mouseDown, false);
2961
- document.removeEventListener('touchend', this.mouseUp, false);
2987
+ this.body.removeChild(this.menu);
2988
+ this.dom.removeEventListener('mousedown', this.mouseDown, false);
2989
+ this.dom.removeEventListener('mouseup', this.mouseUp, false);
2990
+ this.dom.removeEventListener('touchstart', this.mouseDown, false);
2991
+ this.dom.removeEventListener('touchend', this.mouseUp, false);
2962
2992
  this.isAttached = false;
2963
2993
  }
2964
2994
  }
2965
2995
  }
2966
2996
 
2967
2997
  class ContextMenuController {
2968
- constructor(documentBody, theme, configuration, itemsBuilder) {
2969
- this.documentBody = documentBody;
2998
+ constructor(theme, configuration, itemsBuilder) {
2970
2999
  this.theme = theme;
2971
3000
  this.configuration = configuration;
2972
3001
  this.itemsBuilder = itemsBuilder;
@@ -2980,7 +3009,7 @@ class ContextMenuController {
2980
3009
  this.current.tryDestroy();
2981
3010
  }
2982
3011
  const items = this.itemsBuilder.build(commandOrNull);
2983
- this.current = ContextMenu.create(this.documentBody, position, this.theme, items);
3012
+ this.current = ContextMenu.create(this.configuration.shadowRoot, position, this.theme, items);
2984
3013
  }
2985
3014
  destroy() {
2986
3015
  if (this.current) {
@@ -3082,7 +3111,7 @@ class Workspace {
3082
3111
  const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3083
3112
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
3084
3113
  : undefined);
3085
- const contextMenuController = new ContextMenuController(designerContext.documentBody, designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3114
+ const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3086
3115
  const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
3087
3116
  setTimeout(() => {
3088
3117
  workspace.updateRootComponent();
@@ -3513,22 +3542,25 @@ class ControlBarExtension {
3513
3542
  const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
3514
3543
  class KeyboardDaemon {
3515
3544
  static create(api, configuration) {
3516
- const controller = new KeyboardDaemon(api.controlBar, configuration);
3517
- document.addEventListener('keyup', controller.onKeyUp, false);
3545
+ const dom = api.shadowRoot || document;
3546
+ const controller = new KeyboardDaemon(dom, api.controlBar, configuration);
3547
+ dom.addEventListener('keyup', controller.onKeyUp, false);
3518
3548
  return controller;
3519
3549
  }
3520
- constructor(controlBarApi, configuration) {
3550
+ constructor(dom, controlBarApi, configuration) {
3551
+ this.dom = dom;
3521
3552
  this.controlBarApi = controlBarApi;
3522
3553
  this.configuration = configuration;
3523
3554
  this.onKeyUp = (e) => {
3524
- const action = detectAction(e);
3555
+ const ke = e;
3556
+ const action = detectAction(ke);
3525
3557
  if (!action) {
3526
3558
  return;
3527
3559
  }
3528
3560
  if (document.activeElement && ignoreTagNames.includes(document.activeElement.tagName)) {
3529
3561
  return;
3530
3562
  }
3531
- if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, e)) {
3563
+ if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, ke)) {
3532
3564
  return;
3533
3565
  }
3534
3566
  const isDeletable = this.controlBarApi.canDelete();
@@ -3540,7 +3572,7 @@ class KeyboardDaemon {
3540
3572
  };
3541
3573
  }
3542
3574
  destroy() {
3543
- document.removeEventListener('keyup', this.onKeyUp, false);
3575
+ this.dom.removeEventListener('keyup', this.onKeyUp, false);
3544
3576
  }
3545
3577
  }
3546
3578
  function detectAction(e) {
@@ -4397,12 +4429,11 @@ class Designer {
4397
4429
  }
4398
4430
  const config = configuration;
4399
4431
  validateConfiguration(config);
4400
- const documentBody = (_a = configuration.documentBody) !== null && _a !== void 0 ? _a : document.body;
4401
- if (!isElementAttached(placeholder, documentBody)) {
4432
+ if (!isElementAttached((_a = config.shadowRoot) !== null && _a !== void 0 ? _a : document, placeholder)) {
4402
4433
  throw new Error('Placeholder is not attached to the DOM');
4403
4434
  }
4404
4435
  const services = ServicesResolver.resolve(configuration.extensions, config);
4405
- const designerContext = DesignerContext.create(documentBody, placeholder, startDefinition, config, services);
4436
+ const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
4406
4437
  const designerApi = DesignerApi.create(designerContext);
4407
4438
  const view = DesignerView.create(placeholder, designerContext, designerApi);
4408
4439
  const designer = new Designer(view, designerContext.state, designerContext.stateModifier, designerContext.definitionWalker, designerContext.historyController, designerApi);
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
- componentContext.documentBody.appendChild(layer);
410
+ body.appendChild(layer);
409
411
  const component = componentContext.services.draggedComponent.create(layer, step, componentContext);
410
- return new DragStepView(component, layer, componentContext.documentBody);
412
+ return new DragStepView(component, layer, body);
411
413
  }
412
- constructor(component, layer, documentBody) {
414
+ constructor(component, layer, body) {
413
415
  this.component = component;
414
416
  this.layer = layer;
415
- this.documentBody = documentBody;
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.documentBody.removeChild(this.layer);
425
+ this.body.removeChild(this.layer);
424
426
  }
425
427
  }
426
428
 
@@ -725,9 +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(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);
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(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
732
+ constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
733
+ this.shadowRoot = shadowRoot;
731
734
  this.controlBar = controlBar;
732
735
  this.toolbox = toolbox;
733
736
  this.editor = editor;
@@ -966,13 +969,14 @@ class StepComponentFactory {
966
969
  }
967
970
 
968
971
  class ComponentContext {
969
- static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services, documentBody) {
972
+ static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
970
973
  const validator = new DefinitionValidator(configuration.validator, state);
971
974
  const iconProvider = new IconProvider(configuration.steps);
972
975
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
973
- return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, documentBody);
976
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
974
977
  }
975
- constructor(validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n, documentBody) {
978
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
979
+ this.shadowRoot = shadowRoot;
976
980
  this.validator = validator;
977
981
  this.iconProvider = iconProvider;
978
982
  this.placeholderController = placeholderController;
@@ -981,7 +985,6 @@ class ComponentContext {
981
985
  this.services = services;
982
986
  this.preferenceStorage = preferenceStorage;
983
987
  this.i18n = i18n;
984
- this.documentBody = documentBody;
985
988
  }
986
989
  }
987
990
 
@@ -2048,31 +2051,41 @@ const nonPassiveOptions = {
2048
2051
  passive: false
2049
2052
  };
2050
2053
  class BehaviorController {
2051
- constructor() {
2054
+ static create(shadowRoot) {
2055
+ return new BehaviorController(shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document, shadowRoot);
2056
+ }
2057
+ constructor(dom, shadowRoot) {
2058
+ this.dom = dom;
2059
+ this.shadowRoot = shadowRoot;
2052
2060
  this.onMouseMove = (e) => {
2053
2061
  e.preventDefault();
2062
+ e.stopPropagation();
2054
2063
  this.move(readMousePosition(e));
2055
2064
  };
2056
2065
  this.onTouchMove = (e) => {
2057
2066
  e.preventDefault();
2067
+ e.stopPropagation();
2058
2068
  this.move(readTouchPosition(e));
2059
2069
  };
2060
2070
  this.onMouseUp = (e) => {
2061
2071
  e.preventDefault();
2072
+ e.stopPropagation();
2062
2073
  this.stop(false, e.target);
2063
2074
  };
2064
2075
  this.onTouchEnd = (e) => {
2065
2076
  var _a;
2066
2077
  e.preventDefault();
2078
+ e.stopPropagation();
2067
2079
  if (!this.state) {
2068
2080
  throw new Error(notInitializedError);
2069
2081
  }
2070
2082
  const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
2071
- const element = document.elementFromPoint(position.x, position.y);
2083
+ const element = this.dom.elementFromPoint(position.x, position.y);
2072
2084
  this.stop(false, element);
2073
2085
  };
2074
2086
  this.onTouchStart = (e) => {
2075
2087
  e.preventDefault();
2088
+ e.stopPropagation();
2076
2089
  if (e.touches.length !== 1) {
2077
2090
  this.stop(true, null);
2078
2091
  }
@@ -2088,11 +2101,24 @@ class BehaviorController {
2088
2101
  behavior
2089
2102
  };
2090
2103
  behavior.onStart(this.state.startPosition);
2091
- window.addEventListener('mousemove', this.onMouseMove, false);
2092
- window.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2093
- window.addEventListener('mouseup', this.onMouseUp, false);
2094
- window.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2095
- window.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2104
+ if (this.shadowRoot) {
2105
+ this.bind(this.shadowRoot);
2106
+ }
2107
+ this.bind(window);
2108
+ }
2109
+ bind(target) {
2110
+ target.addEventListener('mousemove', this.onMouseMove, false);
2111
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2112
+ target.addEventListener('mouseup', this.onMouseUp, false);
2113
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2114
+ target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2115
+ }
2116
+ unbind(target) {
2117
+ target.removeEventListener('mousemove', this.onMouseMove, false);
2118
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2119
+ target.removeEventListener('mouseup', this.onMouseUp, false);
2120
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2121
+ target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2096
2122
  }
2097
2123
  move(position) {
2098
2124
  if (!this.state) {
@@ -2112,11 +2138,10 @@ class BehaviorController {
2112
2138
  if (!this.state) {
2113
2139
  throw new Error(notInitializedError);
2114
2140
  }
2115
- window.removeEventListener('mousemove', this.onMouseMove, false);
2116
- window.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2117
- window.removeEventListener('mouseup', this.onMouseUp, false);
2118
- window.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2119
- window.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2141
+ if (this.shadowRoot) {
2142
+ this.unbind(this.shadowRoot);
2143
+ }
2144
+ this.unbind(window);
2120
2145
  this.state.behavior.onEnd(interrupt, element);
2121
2146
  this.state = undefined;
2122
2147
  }
@@ -2479,11 +2504,11 @@ function areItemsEqual(item, changeType, stepId) {
2479
2504
  }
2480
2505
 
2481
2506
  class LayoutController {
2482
- constructor(parent) {
2483
- this.parent = parent;
2507
+ constructor(placeholder) {
2508
+ this.placeholder = placeholder;
2484
2509
  }
2485
2510
  isMobile() {
2486
- return this.parent.clientWidth < 400; // TODO
2511
+ return this.placeholder.clientWidth < 400; // TODO
2487
2512
  }
2488
2513
  }
2489
2514
 
@@ -2540,18 +2565,18 @@ class MemoryPreferenceStorage {
2540
2565
  }
2541
2566
 
2542
2567
  class DesignerContext {
2543
- static create(documentBody, parent, startDefinition, configuration, services) {
2568
+ static create(placeholder, startDefinition, configuration, services) {
2544
2569
  var _a, _b, _c, _d, _e;
2545
2570
  const definition = ObjectCloner.deepClone(startDefinition);
2546
- const layoutController = new LayoutController(parent);
2547
- const isReadonly = !!configuration.isReadonly;
2571
+ const layoutController = new LayoutController(placeholder);
2572
+ const isReadonly = Boolean(configuration.isReadonly);
2548
2573
  const isToolboxCollapsed = configuration.toolbox ? (_a = configuration.toolbox.isCollapsed) !== null && _a !== void 0 ? _a : layoutController.isMobile() : false;
2549
2574
  const isEditorCollapsed = configuration.editors ? (_b = configuration.editors.isCollapsed) !== null && _b !== void 0 ? _b : layoutController.isMobile() : false;
2550
2575
  const theme = configuration.theme || 'light';
2551
2576
  const state = new DesignerState(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed);
2552
2577
  const workspaceController = new WorkspaceControllerWrapper();
2553
2578
  const placeholderController = services.placeholderController.create();
2554
- const behaviorController = new BehaviorController();
2579
+ const behaviorController = BehaviorController.create(configuration.shadowRoot);
2555
2580
  const stepExtensionResolver = StepExtensionResolver.create(services);
2556
2581
  const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
2557
2582
  const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
@@ -2562,11 +2587,10 @@ class DesignerContext {
2562
2587
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
2563
2588
  }
2564
2589
  const preferenceStorage = (_e = configuration.preferenceStorage) !== null && _e !== void 0 ? _e : new MemoryPreferenceStorage();
2565
- const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services, documentBody);
2566
- return new DesignerContext(documentBody, theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
2590
+ const componentContext = ComponentContext.create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services);
2591
+ return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController);
2567
2592
  }
2568
- constructor(documentBody, theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
2569
- this.documentBody = documentBody;
2593
+ constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, placeholderController, behaviorController, customActionController, historyController) {
2570
2594
  this.theme = theme;
2571
2595
  this.state = state;
2572
2596
  this.configuration = configuration;
@@ -2612,8 +2636,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
2612
2636
  });
2613
2637
  }
2614
2638
 
2615
- function isElementAttached(element, documentBody) {
2616
- return !(documentBody.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2639
+ function isElementAttached(dom, element) {
2640
+ return !(dom.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
2617
2641
  }
2618
2642
 
2619
2643
  let lastGridPatternId = 0;
@@ -2647,11 +2671,12 @@ class WorkspaceView {
2647
2671
  canvas.appendChild(foreground);
2648
2672
  workspace.appendChild(canvas);
2649
2673
  parent.appendChild(workspace);
2650
- const view = new WorkspaceView(workspace, canvas, pattern, gridPattern, foreground, componentContext);
2674
+ const view = new WorkspaceView(componentContext.shadowRoot, workspace, canvas, pattern, gridPattern, foreground, componentContext);
2651
2675
  window.addEventListener('resize', view.onResizeHandler, false);
2652
2676
  return view;
2653
2677
  }
2654
- constructor(workspace, canvas, pattern, gridPattern, foreground, context) {
2678
+ constructor(shadowRoot, workspace, canvas, pattern, gridPattern, foreground, context) {
2679
+ this.shadowRoot = shadowRoot;
2655
2680
  this.workspace = workspace;
2656
2681
  this.canvas = canvas;
2657
2682
  this.pattern = pattern;
@@ -2692,9 +2717,11 @@ class WorkspaceView {
2692
2717
  handler(readMousePosition(e), e.target, e.button, e.altKey);
2693
2718
  }, false);
2694
2719
  this.canvas.addEventListener('touchstart', e => {
2720
+ var _a;
2695
2721
  e.preventDefault();
2696
2722
  const clientPosition = readTouchClientPosition(e);
2697
- const element = document.elementFromPoint(clientPosition.x, clientPosition.y);
2723
+ const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
2724
+ const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
2698
2725
  if (element) {
2699
2726
  const position = readTouchPosition(e);
2700
2727
  handler(position, element, 0, false);
@@ -2877,7 +2904,7 @@ function findValidationBadgeIndex(extensions) {
2877
2904
  }
2878
2905
 
2879
2906
  class ContextMenu {
2880
- static create(documentBody, position, theme, items) {
2907
+ static create(shadowRoot, position, theme, items) {
2881
2908
  const menu = document.createElement('div');
2882
2909
  menu.style.left = `${position.x}px`;
2883
2910
  menu.style.top = `${position.y}px`;
@@ -2897,16 +2924,19 @@ class ContextMenu {
2897
2924
  elements.push(element);
2898
2925
  menu.appendChild(element);
2899
2926
  }
2900
- const instance = new ContextMenu(documentBody, menu, elements, items, Date.now());
2901
- document.addEventListener('mousedown', instance.mouseDown, false);
2902
- document.addEventListener('mouseup', instance.mouseUp, false);
2903
- document.addEventListener('touchstart', instance.mouseDown, false);
2904
- document.addEventListener('touchend', instance.mouseUp, false);
2905
- documentBody.appendChild(menu);
2927
+ const body = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document.body;
2928
+ const dom = shadowRoot !== null && shadowRoot !== void 0 ? shadowRoot : document;
2929
+ const instance = new ContextMenu(body, dom, menu, elements, items, Date.now());
2930
+ dom.addEventListener('mousedown', instance.mouseDown, false);
2931
+ dom.addEventListener('mouseup', instance.mouseUp, false);
2932
+ dom.addEventListener('touchstart', instance.mouseDown, false);
2933
+ dom.addEventListener('touchend', instance.mouseUp, false);
2934
+ body.appendChild(menu);
2906
2935
  return instance;
2907
2936
  }
2908
- constructor(documentBody, menu, elements, items, startTime) {
2909
- this.documentBody = documentBody;
2937
+ constructor(body, dom, menu, elements, items, startTime) {
2938
+ this.body = body;
2939
+ this.dom = dom;
2910
2940
  this.menu = menu;
2911
2941
  this.elements = elements;
2912
2942
  this.items = items;
@@ -2953,19 +2983,18 @@ class ContextMenu {
2953
2983
  }
2954
2984
  tryDestroy() {
2955
2985
  if (this.isAttached) {
2956
- this.documentBody.removeChild(this.menu);
2957
- document.removeEventListener('mousedown', this.mouseDown, false);
2958
- document.removeEventListener('mouseup', this.mouseUp, false);
2959
- document.removeEventListener('touchstart', this.mouseDown, false);
2960
- document.removeEventListener('touchend', this.mouseUp, false);
2986
+ this.body.removeChild(this.menu);
2987
+ this.dom.removeEventListener('mousedown', this.mouseDown, false);
2988
+ this.dom.removeEventListener('mouseup', this.mouseUp, false);
2989
+ this.dom.removeEventListener('touchstart', this.mouseDown, false);
2990
+ this.dom.removeEventListener('touchend', this.mouseUp, false);
2961
2991
  this.isAttached = false;
2962
2992
  }
2963
2993
  }
2964
2994
  }
2965
2995
 
2966
2996
  class ContextMenuController {
2967
- constructor(documentBody, theme, configuration, itemsBuilder) {
2968
- this.documentBody = documentBody;
2997
+ constructor(theme, configuration, itemsBuilder) {
2969
2998
  this.theme = theme;
2970
2999
  this.configuration = configuration;
2971
3000
  this.itemsBuilder = itemsBuilder;
@@ -2979,7 +3008,7 @@ class ContextMenuController {
2979
3008
  this.current.tryDestroy();
2980
3009
  }
2981
3010
  const items = this.itemsBuilder.build(commandOrNull);
2982
- this.current = ContextMenu.create(this.documentBody, position, this.theme, items);
3011
+ this.current = ContextMenu.create(this.configuration.shadowRoot, position, this.theme, items);
2983
3012
  }
2984
3013
  destroy() {
2985
3014
  if (this.current) {
@@ -3081,7 +3110,7 @@ class Workspace {
3081
3110
  const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3082
3111
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
3083
3112
  : undefined);
3084
- const contextMenuController = new ContextMenuController(designerContext.documentBody, designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3113
+ const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3085
3114
  const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
3086
3115
  setTimeout(() => {
3087
3116
  workspace.updateRootComponent();
@@ -3512,22 +3541,25 @@ class ControlBarExtension {
3512
3541
  const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
3513
3542
  class KeyboardDaemon {
3514
3543
  static create(api, configuration) {
3515
- const controller = new KeyboardDaemon(api.controlBar, configuration);
3516
- document.addEventListener('keyup', controller.onKeyUp, false);
3544
+ const dom = api.shadowRoot || document;
3545
+ const controller = new KeyboardDaemon(dom, api.controlBar, configuration);
3546
+ dom.addEventListener('keyup', controller.onKeyUp, false);
3517
3547
  return controller;
3518
3548
  }
3519
- constructor(controlBarApi, configuration) {
3549
+ constructor(dom, controlBarApi, configuration) {
3550
+ this.dom = dom;
3520
3551
  this.controlBarApi = controlBarApi;
3521
3552
  this.configuration = configuration;
3522
3553
  this.onKeyUp = (e) => {
3523
- const action = detectAction(e);
3554
+ const ke = e;
3555
+ const action = detectAction(ke);
3524
3556
  if (!action) {
3525
3557
  return;
3526
3558
  }
3527
3559
  if (document.activeElement && ignoreTagNames.includes(document.activeElement.tagName)) {
3528
3560
  return;
3529
3561
  }
3530
- if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, e)) {
3562
+ if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, ke)) {
3531
3563
  return;
3532
3564
  }
3533
3565
  const isDeletable = this.controlBarApi.canDelete();
@@ -3539,7 +3571,7 @@ class KeyboardDaemon {
3539
3571
  };
3540
3572
  }
3541
3573
  destroy() {
3542
- document.removeEventListener('keyup', this.onKeyUp, false);
3574
+ this.dom.removeEventListener('keyup', this.onKeyUp, false);
3543
3575
  }
3544
3576
  }
3545
3577
  function detectAction(e) {
@@ -4396,12 +4428,11 @@ class Designer {
4396
4428
  }
4397
4429
  const config = configuration;
4398
4430
  validateConfiguration(config);
4399
- const documentBody = (_a = configuration.documentBody) !== null && _a !== void 0 ? _a : document.body;
4400
- if (!isElementAttached(placeholder, documentBody)) {
4431
+ if (!isElementAttached((_a = config.shadowRoot) !== null && _a !== void 0 ? _a : document, placeholder)) {
4401
4432
  throw new Error('Placeholder is not attached to the DOM');
4402
4433
  }
4403
4434
  const services = ServicesResolver.resolve(configuration.extensions, config);
4404
- const designerContext = DesignerContext.create(documentBody, placeholder, startDefinition, config, services);
4435
+ const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
4405
4436
  const designerApi = DesignerApi.create(designerContext);
4406
4437
  const view = DesignerView.create(placeholder, designerContext, designerApi);
4407
4438
  const designer = new Designer(view, designerContext.state, designerContext.stateModifier, designerContext.definitionWalker, designerContext.historyController, designerApi);
package/lib/index.d.ts CHANGED
@@ -75,8 +75,14 @@ interface Behavior {
75
75
  }
76
76
 
77
77
  declare class BehaviorController {
78
+ private readonly dom;
79
+ private readonly shadowRoot;
78
80
  private state?;
81
+ static create(shadowRoot: ShadowRoot | undefined): BehaviorController;
82
+ private constructor();
79
83
  start(startPosition: Vector, behavior: Behavior): void;
84
+ private bind;
85
+ private unbind;
80
86
  private readonly onMouseMove;
81
87
  private readonly onTouchMove;
82
88
  private readonly onMouseUp;
@@ -271,6 +277,7 @@ declare class StepComponentFactory {
271
277
  }
272
278
 
273
279
  declare class ComponentContext {
280
+ readonly shadowRoot: ShadowRoot | undefined;
274
281
  readonly validator: DefinitionValidator;
275
282
  readonly iconProvider: IconProvider;
276
283
  readonly placeholderController: PlaceholderController;
@@ -279,8 +286,7 @@ declare class ComponentContext {
279
286
  readonly services: Services;
280
287
  readonly preferenceStorage: PreferenceStorage;
281
288
  readonly i18n: I18n;
282
- readonly documentBody: Node;
283
- static create(configuration: DesignerConfiguration, state: DesignerState, stepExtensionResolver: StepExtensionResolver, definitionWalker: DefinitionWalker, preferenceStorage: PreferenceStorage, placeholderController: PlaceholderController, i18n: I18n, services: Services, documentBody: Node): ComponentContext;
289
+ static create(configuration: DesignerConfiguration, state: DesignerState, stepExtensionResolver: StepExtensionResolver, definitionWalker: DefinitionWalker, preferenceStorage: PreferenceStorage, placeholderController: PlaceholderController, i18n: I18n, services: Services): ComponentContext;
284
290
  private constructor();
285
291
  }
286
292
 
@@ -313,8 +319,8 @@ declare class HistoryController {
313
319
  }
314
320
 
315
321
  declare class LayoutController {
316
- private readonly parent;
317
- constructor(parent: HTMLElement);
322
+ private readonly placeholder;
323
+ constructor(placeholder: HTMLElement);
318
324
  isMobile(): boolean;
319
325
  }
320
326
 
@@ -343,7 +349,6 @@ declare class WorkspaceControllerWrapper implements WorkspaceController {
343
349
  }
344
350
 
345
351
  declare class DesignerContext {
346
- readonly documentBody: Node;
347
352
  readonly theme: string;
348
353
  readonly state: DesignerState;
349
354
  readonly configuration: DesignerConfiguration;
@@ -358,8 +363,8 @@ declare class DesignerContext {
358
363
  readonly behaviorController: BehaviorController;
359
364
  readonly customActionController: CustomActionController;
360
365
  readonly historyController: HistoryController | undefined;
361
- static create(documentBody: Node, parent: HTMLElement, startDefinition: Definition, configuration: DesignerConfiguration, services: Services): DesignerContext;
362
- constructor(documentBody: Node, 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);
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);
363
368
  setWorkspaceController(controller: WorkspaceController): void;
364
369
  }
365
370
 
@@ -479,6 +484,7 @@ declare class WorkspaceApi {
479
484
  }
480
485
 
481
486
  declare class DesignerApi {
487
+ readonly shadowRoot: ShadowRoot | undefined;
482
488
  readonly controlBar: ControlBarApi;
483
489
  readonly toolbox: ToolboxApi;
484
490
  readonly editor: EditorApi;
@@ -938,9 +944,9 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
938
944
  */
939
945
  i18n?: I18n;
940
946
  /**
941
- * @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.
942
948
  */
943
- documentBody?: Node;
949
+ shadowRoot?: ShadowRoot;
944
950
  }
945
951
  type UidGenerator = () => string;
946
952
  type I18n = (key: string, defaultValue: string) => string;
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.3",
4
+ "version": "0.24.5",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",