sequential-workflow-designer 0.23.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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.23.0/css/designer.css" rel="stylesheet">
107
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.23.0/css/designer-light.css" rel="stylesheet">
108
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.23.0/css/designer-dark.css" rel="stylesheet">
109
- <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.23.0/dist/index.umd.js"></script>
106
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.1/css/designer.css" rel="stylesheet">
107
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.1/css/designer-light.css" rel="stylesheet">
108
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.1/css/designer-dark.css" rel="stylesheet">
109
+ <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.24.1/dist/index.umd.js"></script>
110
110
  ```
111
111
 
112
112
  Call the designer by:
package/dist/index.umd.js CHANGED
@@ -3436,8 +3436,8 @@
3436
3436
  const uiComponents = designerContext.services.uiComponents.map(factory => factory.create(root, api));
3437
3437
  const daemons = designerContext.services.daemons.map(factory => factory.create(api));
3438
3438
  const view = new DesignerView(root, designerContext.layoutController, workspace, uiComponents, daemons);
3439
- view.reloadLayout();
3440
- window.addEventListener('resize', view.onResizeHandler, false);
3439
+ view.applyLayout();
3440
+ window.addEventListener('resize', view.onResize, false);
3441
3441
  return view;
3442
3442
  }
3443
3443
  constructor(root, layoutController, workspace, uiComponents, daemons) {
@@ -3446,20 +3446,25 @@
3446
3446
  this.workspace = workspace;
3447
3447
  this.uiComponents = uiComponents;
3448
3448
  this.daemons = daemons;
3449
- this.onResizeHandler = () => this.onResize();
3449
+ this.onResize = () => {
3450
+ this.updateLayout();
3451
+ };
3452
+ }
3453
+ updateLayout() {
3454
+ this.applyLayout();
3455
+ for (const component of this.uiComponents) {
3456
+ component.updateLayout();
3457
+ }
3450
3458
  }
3451
3459
  destroy() {
3452
3460
  var _a;
3453
- window.removeEventListener('resize', this.onResizeHandler, false);
3461
+ window.removeEventListener('resize', this.onResize, false);
3454
3462
  this.workspace.destroy();
3455
3463
  this.uiComponents.forEach(component => component.destroy());
3456
3464
  this.daemons.forEach(daemon => daemon.destroy());
3457
3465
  (_a = this.root.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.root);
3458
3466
  }
3459
- onResize() {
3460
- this.reloadLayout();
3461
- }
3462
- reloadLayout() {
3467
+ applyLayout() {
3463
3468
  const isMobile = this.layoutController.isMobile();
3464
3469
  Dom.toggleClass(this.root, !isMobile, 'sqd-layout-desktop');
3465
3470
  Dom.toggleClass(this.root, isMobile, 'sqd-layout-mobile');
@@ -3628,6 +3633,9 @@
3628
3633
  this.controlBarApi = controlBarApi;
3629
3634
  this.isUndoRedoSupported = isUndoRedoSupported;
3630
3635
  }
3636
+ updateLayout() {
3637
+ //
3638
+ }
3631
3639
  destroy() {
3632
3640
  //
3633
3641
  }
@@ -3803,6 +3811,9 @@
3803
3811
  updateVisibility() {
3804
3812
  this.setIsCollapsed(this.editorApi.isCollapsed());
3805
3813
  }
3814
+ updateLayout() {
3815
+ //
3816
+ }
3806
3817
  destroy() {
3807
3818
  this.view.destroy();
3808
3819
  }
@@ -3828,7 +3839,6 @@
3828
3839
  });
3829
3840
  parent.appendChild(root);
3830
3841
  const view = new ScrollBoxView(root, viewport);
3831
- window.addEventListener('resize', view.onResize, false);
3832
3842
  root.addEventListener('wheel', e => view.onWheel(e), listenerOptions);
3833
3843
  root.addEventListener('touchstart', e => view.onTouchStart(e), listenerOptions);
3834
3844
  root.addEventListener('mousedown', e => view.onMouseDown(e), false);
@@ -3837,9 +3847,6 @@
3837
3847
  constructor(root, viewport) {
3838
3848
  this.root = root;
3839
3849
  this.viewport = viewport;
3840
- this.onResize = () => {
3841
- this.refresh();
3842
- };
3843
3850
  this.onTouchStart = (e) => {
3844
3851
  e.preventDefault();
3845
3852
  this.startScroll(readTouchPosition(e));
@@ -3873,13 +3880,13 @@
3873
3880
  this.root.appendChild(element);
3874
3881
  this.reload(element);
3875
3882
  }
3876
- refresh() {
3883
+ updateLayout() {
3877
3884
  if (this.content) {
3878
3885
  this.reload(this.content.element);
3879
3886
  }
3880
3887
  }
3881
3888
  destroy() {
3882
- window.removeEventListener('resize', this.onResize, false);
3889
+ //
3883
3890
  }
3884
3891
  reload(element) {
3885
3892
  const maxHeightPercent = 0.7;
@@ -4064,6 +4071,9 @@
4064
4071
  this.scrollBoxView = scrollBoxView;
4065
4072
  this.api = api;
4066
4073
  }
4074
+ updateLayout() {
4075
+ this.scrollBoxView.updateLayout();
4076
+ }
4067
4077
  bindToggleClick(handler) {
4068
4078
  function forward(e) {
4069
4079
  e.preventDefault();
@@ -4086,7 +4096,7 @@
4086
4096
  this.headerToggleIcon = Icons.createSvg('sqd-toolbox-toggle-icon', isCollapsed ? Icons.expand : Icons.close);
4087
4097
  this.header.appendChild(this.headerToggleIcon);
4088
4098
  if (!isCollapsed) {
4089
- this.scrollBoxView.refresh();
4099
+ this.updateLayout();
4090
4100
  }
4091
4101
  }
4092
4102
  setGroups(groups) {
@@ -4123,6 +4133,9 @@
4123
4133
  this.api = api;
4124
4134
  this.allGroups = allGroups;
4125
4135
  }
4136
+ updateLayout() {
4137
+ this.view.updateLayout();
4138
+ }
4126
4139
  destroy() {
4127
4140
  this.view.destroy();
4128
4141
  }
@@ -4558,14 +4571,14 @@
4558
4571
  if (!placeholder) {
4559
4572
  throw new Error('Placeholder is not defined');
4560
4573
  }
4561
- if (!isElementAttached(placeholder)) {
4562
- throw new Error('Placeholder is not attached to the DOM');
4563
- }
4564
4574
  if (!startDefinition) {
4565
4575
  throw new Error('Start definition is not defined');
4566
4576
  }
4567
4577
  const config = configuration;
4568
4578
  validateConfiguration(config);
4579
+ if (!config.disableDomAttachmentCheck && !isElementAttached(placeholder)) {
4580
+ throw new Error('Placeholder is not attached to the DOM');
4581
+ }
4569
4582
  const services = ServicesResolver.resolve(configuration.extensions, config);
4570
4583
  const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
4571
4584
  const designerApi = DesignerApi.create(designerContext);
@@ -4684,6 +4697,13 @@
4684
4697
  updateRootComponent() {
4685
4698
  this.api.workspace.updateRootComponent();
4686
4699
  }
4700
+ /**
4701
+ * @description Updates the layout of the designer.
4702
+ */
4703
+ updateLayout() {
4704
+ this.api.workspace.updateCanvasSize();
4705
+ this.view.updateLayout();
4706
+ }
4687
4707
  /**
4688
4708
  * @description Updates all badges.
4689
4709
  */
package/lib/cjs/index.cjs CHANGED
@@ -3251,8 +3251,8 @@ class DesignerView {
3251
3251
  const uiComponents = designerContext.services.uiComponents.map(factory => factory.create(root, api));
3252
3252
  const daemons = designerContext.services.daemons.map(factory => factory.create(api));
3253
3253
  const view = new DesignerView(root, designerContext.layoutController, workspace, uiComponents, daemons);
3254
- view.reloadLayout();
3255
- window.addEventListener('resize', view.onResizeHandler, false);
3254
+ view.applyLayout();
3255
+ window.addEventListener('resize', view.onResize, false);
3256
3256
  return view;
3257
3257
  }
3258
3258
  constructor(root, layoutController, workspace, uiComponents, daemons) {
@@ -3261,20 +3261,25 @@ class DesignerView {
3261
3261
  this.workspace = workspace;
3262
3262
  this.uiComponents = uiComponents;
3263
3263
  this.daemons = daemons;
3264
- this.onResizeHandler = () => this.onResize();
3264
+ this.onResize = () => {
3265
+ this.updateLayout();
3266
+ };
3267
+ }
3268
+ updateLayout() {
3269
+ this.applyLayout();
3270
+ for (const component of this.uiComponents) {
3271
+ component.updateLayout();
3272
+ }
3265
3273
  }
3266
3274
  destroy() {
3267
3275
  var _a;
3268
- window.removeEventListener('resize', this.onResizeHandler, false);
3276
+ window.removeEventListener('resize', this.onResize, false);
3269
3277
  this.workspace.destroy();
3270
3278
  this.uiComponents.forEach(component => component.destroy());
3271
3279
  this.daemons.forEach(daemon => daemon.destroy());
3272
3280
  (_a = this.root.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.root);
3273
3281
  }
3274
- onResize() {
3275
- this.reloadLayout();
3276
- }
3277
- reloadLayout() {
3282
+ applyLayout() {
3278
3283
  const isMobile = this.layoutController.isMobile();
3279
3284
  Dom.toggleClass(this.root, !isMobile, 'sqd-layout-desktop');
3280
3285
  Dom.toggleClass(this.root, isMobile, 'sqd-layout-mobile');
@@ -3443,6 +3448,9 @@ class ControlBar {
3443
3448
  this.controlBarApi = controlBarApi;
3444
3449
  this.isUndoRedoSupported = isUndoRedoSupported;
3445
3450
  }
3451
+ updateLayout() {
3452
+ //
3453
+ }
3446
3454
  destroy() {
3447
3455
  //
3448
3456
  }
@@ -3618,6 +3626,9 @@ class SmartEditor {
3618
3626
  updateVisibility() {
3619
3627
  this.setIsCollapsed(this.editorApi.isCollapsed());
3620
3628
  }
3629
+ updateLayout() {
3630
+ //
3631
+ }
3621
3632
  destroy() {
3622
3633
  this.view.destroy();
3623
3634
  }
@@ -3643,7 +3654,6 @@ class ScrollBoxView {
3643
3654
  });
3644
3655
  parent.appendChild(root);
3645
3656
  const view = new ScrollBoxView(root, viewport);
3646
- window.addEventListener('resize', view.onResize, false);
3647
3657
  root.addEventListener('wheel', e => view.onWheel(e), listenerOptions);
3648
3658
  root.addEventListener('touchstart', e => view.onTouchStart(e), listenerOptions);
3649
3659
  root.addEventListener('mousedown', e => view.onMouseDown(e), false);
@@ -3652,9 +3662,6 @@ class ScrollBoxView {
3652
3662
  constructor(root, viewport) {
3653
3663
  this.root = root;
3654
3664
  this.viewport = viewport;
3655
- this.onResize = () => {
3656
- this.refresh();
3657
- };
3658
3665
  this.onTouchStart = (e) => {
3659
3666
  e.preventDefault();
3660
3667
  this.startScroll(readTouchPosition(e));
@@ -3688,13 +3695,13 @@ class ScrollBoxView {
3688
3695
  this.root.appendChild(element);
3689
3696
  this.reload(element);
3690
3697
  }
3691
- refresh() {
3698
+ updateLayout() {
3692
3699
  if (this.content) {
3693
3700
  this.reload(this.content.element);
3694
3701
  }
3695
3702
  }
3696
3703
  destroy() {
3697
- window.removeEventListener('resize', this.onResize, false);
3704
+ //
3698
3705
  }
3699
3706
  reload(element) {
3700
3707
  const maxHeightPercent = 0.7;
@@ -3879,6 +3886,9 @@ class ToolboxView {
3879
3886
  this.scrollBoxView = scrollBoxView;
3880
3887
  this.api = api;
3881
3888
  }
3889
+ updateLayout() {
3890
+ this.scrollBoxView.updateLayout();
3891
+ }
3882
3892
  bindToggleClick(handler) {
3883
3893
  function forward(e) {
3884
3894
  e.preventDefault();
@@ -3901,7 +3911,7 @@ class ToolboxView {
3901
3911
  this.headerToggleIcon = Icons.createSvg('sqd-toolbox-toggle-icon', isCollapsed ? Icons.expand : Icons.close);
3902
3912
  this.header.appendChild(this.headerToggleIcon);
3903
3913
  if (!isCollapsed) {
3904
- this.scrollBoxView.refresh();
3914
+ this.updateLayout();
3905
3915
  }
3906
3916
  }
3907
3917
  setGroups(groups) {
@@ -3938,6 +3948,9 @@ class Toolbox {
3938
3948
  this.api = api;
3939
3949
  this.allGroups = allGroups;
3940
3950
  }
3951
+ updateLayout() {
3952
+ this.view.updateLayout();
3953
+ }
3941
3954
  destroy() {
3942
3955
  this.view.destroy();
3943
3956
  }
@@ -4373,14 +4386,14 @@ class Designer {
4373
4386
  if (!placeholder) {
4374
4387
  throw new Error('Placeholder is not defined');
4375
4388
  }
4376
- if (!isElementAttached(placeholder)) {
4377
- throw new Error('Placeholder is not attached to the DOM');
4378
- }
4379
4389
  if (!startDefinition) {
4380
4390
  throw new Error('Start definition is not defined');
4381
4391
  }
4382
4392
  const config = configuration;
4383
4393
  validateConfiguration(config);
4394
+ if (!config.disableDomAttachmentCheck && !isElementAttached(placeholder)) {
4395
+ throw new Error('Placeholder is not attached to the DOM');
4396
+ }
4384
4397
  const services = ServicesResolver.resolve(configuration.extensions, config);
4385
4398
  const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
4386
4399
  const designerApi = DesignerApi.create(designerContext);
@@ -4499,6 +4512,13 @@ class Designer {
4499
4512
  updateRootComponent() {
4500
4513
  this.api.workspace.updateRootComponent();
4501
4514
  }
4515
+ /**
4516
+ * @description Updates the layout of the designer.
4517
+ */
4518
+ updateLayout() {
4519
+ this.api.workspace.updateCanvasSize();
4520
+ this.view.updateLayout();
4521
+ }
4502
4522
  /**
4503
4523
  * @description Updates all badges.
4504
4524
  */
package/lib/esm/index.js CHANGED
@@ -3250,8 +3250,8 @@ class DesignerView {
3250
3250
  const uiComponents = designerContext.services.uiComponents.map(factory => factory.create(root, api));
3251
3251
  const daemons = designerContext.services.daemons.map(factory => factory.create(api));
3252
3252
  const view = new DesignerView(root, designerContext.layoutController, workspace, uiComponents, daemons);
3253
- view.reloadLayout();
3254
- window.addEventListener('resize', view.onResizeHandler, false);
3253
+ view.applyLayout();
3254
+ window.addEventListener('resize', view.onResize, false);
3255
3255
  return view;
3256
3256
  }
3257
3257
  constructor(root, layoutController, workspace, uiComponents, daemons) {
@@ -3260,20 +3260,25 @@ class DesignerView {
3260
3260
  this.workspace = workspace;
3261
3261
  this.uiComponents = uiComponents;
3262
3262
  this.daemons = daemons;
3263
- this.onResizeHandler = () => this.onResize();
3263
+ this.onResize = () => {
3264
+ this.updateLayout();
3265
+ };
3266
+ }
3267
+ updateLayout() {
3268
+ this.applyLayout();
3269
+ for (const component of this.uiComponents) {
3270
+ component.updateLayout();
3271
+ }
3264
3272
  }
3265
3273
  destroy() {
3266
3274
  var _a;
3267
- window.removeEventListener('resize', this.onResizeHandler, false);
3275
+ window.removeEventListener('resize', this.onResize, false);
3268
3276
  this.workspace.destroy();
3269
3277
  this.uiComponents.forEach(component => component.destroy());
3270
3278
  this.daemons.forEach(daemon => daemon.destroy());
3271
3279
  (_a = this.root.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.root);
3272
3280
  }
3273
- onResize() {
3274
- this.reloadLayout();
3275
- }
3276
- reloadLayout() {
3281
+ applyLayout() {
3277
3282
  const isMobile = this.layoutController.isMobile();
3278
3283
  Dom.toggleClass(this.root, !isMobile, 'sqd-layout-desktop');
3279
3284
  Dom.toggleClass(this.root, isMobile, 'sqd-layout-mobile');
@@ -3442,6 +3447,9 @@ class ControlBar {
3442
3447
  this.controlBarApi = controlBarApi;
3443
3448
  this.isUndoRedoSupported = isUndoRedoSupported;
3444
3449
  }
3450
+ updateLayout() {
3451
+ //
3452
+ }
3445
3453
  destroy() {
3446
3454
  //
3447
3455
  }
@@ -3617,6 +3625,9 @@ class SmartEditor {
3617
3625
  updateVisibility() {
3618
3626
  this.setIsCollapsed(this.editorApi.isCollapsed());
3619
3627
  }
3628
+ updateLayout() {
3629
+ //
3630
+ }
3620
3631
  destroy() {
3621
3632
  this.view.destroy();
3622
3633
  }
@@ -3642,7 +3653,6 @@ class ScrollBoxView {
3642
3653
  });
3643
3654
  parent.appendChild(root);
3644
3655
  const view = new ScrollBoxView(root, viewport);
3645
- window.addEventListener('resize', view.onResize, false);
3646
3656
  root.addEventListener('wheel', e => view.onWheel(e), listenerOptions);
3647
3657
  root.addEventListener('touchstart', e => view.onTouchStart(e), listenerOptions);
3648
3658
  root.addEventListener('mousedown', e => view.onMouseDown(e), false);
@@ -3651,9 +3661,6 @@ class ScrollBoxView {
3651
3661
  constructor(root, viewport) {
3652
3662
  this.root = root;
3653
3663
  this.viewport = viewport;
3654
- this.onResize = () => {
3655
- this.refresh();
3656
- };
3657
3664
  this.onTouchStart = (e) => {
3658
3665
  e.preventDefault();
3659
3666
  this.startScroll(readTouchPosition(e));
@@ -3687,13 +3694,13 @@ class ScrollBoxView {
3687
3694
  this.root.appendChild(element);
3688
3695
  this.reload(element);
3689
3696
  }
3690
- refresh() {
3697
+ updateLayout() {
3691
3698
  if (this.content) {
3692
3699
  this.reload(this.content.element);
3693
3700
  }
3694
3701
  }
3695
3702
  destroy() {
3696
- window.removeEventListener('resize', this.onResize, false);
3703
+ //
3697
3704
  }
3698
3705
  reload(element) {
3699
3706
  const maxHeightPercent = 0.7;
@@ -3878,6 +3885,9 @@ class ToolboxView {
3878
3885
  this.scrollBoxView = scrollBoxView;
3879
3886
  this.api = api;
3880
3887
  }
3888
+ updateLayout() {
3889
+ this.scrollBoxView.updateLayout();
3890
+ }
3881
3891
  bindToggleClick(handler) {
3882
3892
  function forward(e) {
3883
3893
  e.preventDefault();
@@ -3900,7 +3910,7 @@ class ToolboxView {
3900
3910
  this.headerToggleIcon = Icons.createSvg('sqd-toolbox-toggle-icon', isCollapsed ? Icons.expand : Icons.close);
3901
3911
  this.header.appendChild(this.headerToggleIcon);
3902
3912
  if (!isCollapsed) {
3903
- this.scrollBoxView.refresh();
3913
+ this.updateLayout();
3904
3914
  }
3905
3915
  }
3906
3916
  setGroups(groups) {
@@ -3937,6 +3947,9 @@ class Toolbox {
3937
3947
  this.api = api;
3938
3948
  this.allGroups = allGroups;
3939
3949
  }
3950
+ updateLayout() {
3951
+ this.view.updateLayout();
3952
+ }
3940
3953
  destroy() {
3941
3954
  this.view.destroy();
3942
3955
  }
@@ -4372,14 +4385,14 @@ class Designer {
4372
4385
  if (!placeholder) {
4373
4386
  throw new Error('Placeholder is not defined');
4374
4387
  }
4375
- if (!isElementAttached(placeholder)) {
4376
- throw new Error('Placeholder is not attached to the DOM');
4377
- }
4378
4388
  if (!startDefinition) {
4379
4389
  throw new Error('Start definition is not defined');
4380
4390
  }
4381
4391
  const config = configuration;
4382
4392
  validateConfiguration(config);
4393
+ if (!config.disableDomAttachmentCheck && !isElementAttached(placeholder)) {
4394
+ throw new Error('Placeholder is not attached to the DOM');
4395
+ }
4383
4396
  const services = ServicesResolver.resolve(configuration.extensions, config);
4384
4397
  const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
4385
4398
  const designerApi = DesignerApi.create(designerContext);
@@ -4498,6 +4511,13 @@ class Designer {
4498
4511
  updateRootComponent() {
4499
4512
  this.api.workspace.updateRootComponent();
4500
4513
  }
4514
+ /**
4515
+ * @description Updates the layout of the designer.
4516
+ */
4517
+ updateLayout() {
4518
+ this.api.workspace.updateCanvasSize();
4519
+ this.view.updateLayout();
4520
+ }
4501
4521
  /**
4502
4522
  * @description Updates all badges.
4503
4523
  */
package/lib/index.d.ts CHANGED
@@ -781,6 +781,7 @@ interface UiComponentExtension {
781
781
  create(root: HTMLElement, api: DesignerApi): UiComponent;
782
782
  }
783
783
  interface UiComponent {
784
+ updateLayout(): void;
784
785
  destroy(): void;
785
786
  }
786
787
  interface DraggedComponentExtension {
@@ -934,6 +935,10 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
934
935
  * @description Custom translation function.
935
936
  */
936
937
  i18n?: I18n;
938
+ /**
939
+ * @description By default, the designer checks if the placeholder is attached to the DOM. This flag may disable this check.
940
+ */
941
+ disableDomAttachmentCheck?: boolean;
937
942
  }
938
943
  type UidGenerator = () => string;
939
944
  type I18n = (key: string, defaultValue: string) => string;
@@ -1184,6 +1189,10 @@ declare class Designer<TDefinition extends Definition = Definition> {
1184
1189
  * @description Rerender the root component and all its children.
1185
1190
  */
1186
1191
  updateRootComponent(): void;
1192
+ /**
1193
+ * @description Updates the layout of the designer.
1194
+ */
1195
+ updateLayout(): void;
1187
1196
  /**
1188
1197
  * @description Updates all badges.
1189
1198
  */
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.23.0",
4
+ "version": "0.24.1",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",