dockview-core 1.14.2 → 1.15.0

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.
Files changed (76) hide show
  1. package/dist/cjs/api/component.api.d.ts +4 -5
  2. package/dist/cjs/api/component.api.js +12 -2
  3. package/dist/cjs/constants.d.ts +2 -0
  4. package/dist/cjs/constants.js +1 -1
  5. package/dist/cjs/dnd/overlay.d.ts +6 -4
  6. package/dist/cjs/dnd/overlay.js +119 -28
  7. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +4 -2
  8. package/dist/cjs/dockview/dockviewComponent.d.ts +20 -17
  9. package/dist/cjs/dockview/dockviewComponent.js +92 -45
  10. package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +3 -12
  11. package/dist/cjs/dockview/options.d.ts +10 -6
  12. package/dist/cjs/dockview/options.js +1 -0
  13. package/dist/cjs/dom.d.ts +1 -0
  14. package/dist/cjs/dom.js +5 -1
  15. package/dist/cjs/gridview/baseComponentGridview.d.ts +3 -0
  16. package/dist/cjs/gridview/baseComponentGridview.js +8 -2
  17. package/dist/cjs/gridview/branchNode.d.ts +7 -3
  18. package/dist/cjs/gridview/branchNode.js +24 -29
  19. package/dist/cjs/gridview/gridview.d.ts +7 -1
  20. package/dist/cjs/gridview/gridview.js +31 -8
  21. package/dist/cjs/gridview/gridviewPanel.d.ts +1 -0
  22. package/dist/cjs/gridview/gridviewPanel.js +7 -0
  23. package/dist/cjs/math.js +5 -1
  24. package/dist/cjs/splitview/splitview.d.ts +13 -0
  25. package/dist/cjs/splitview/splitview.js +42 -12
  26. package/dist/cjs/types.d.ts +23 -0
  27. package/dist/dockview-core.amd.js +317 -110
  28. package/dist/dockview-core.amd.js.map +1 -1
  29. package/dist/dockview-core.amd.min.js +2 -2
  30. package/dist/dockview-core.amd.min.js.map +1 -1
  31. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  32. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  33. package/dist/dockview-core.amd.noStyle.js +316 -109
  34. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  35. package/dist/dockview-core.cjs.js +317 -110
  36. package/dist/dockview-core.cjs.js.map +1 -1
  37. package/dist/dockview-core.esm.js +317 -110
  38. package/dist/dockview-core.esm.js.map +1 -1
  39. package/dist/dockview-core.esm.min.js +2 -2
  40. package/dist/dockview-core.esm.min.js.map +1 -1
  41. package/dist/dockview-core.js +317 -110
  42. package/dist/dockview-core.js.map +1 -1
  43. package/dist/dockview-core.min.js +2 -2
  44. package/dist/dockview-core.min.js.map +1 -1
  45. package/dist/dockview-core.min.noStyle.js +2 -2
  46. package/dist/dockview-core.min.noStyle.js.map +1 -1
  47. package/dist/dockview-core.noStyle.js +316 -109
  48. package/dist/dockview-core.noStyle.js.map +1 -1
  49. package/dist/esm/api/component.api.d.ts +4 -5
  50. package/dist/esm/api/component.api.js +8 -2
  51. package/dist/esm/constants.d.ts +2 -0
  52. package/dist/esm/constants.js +1 -1
  53. package/dist/esm/dnd/overlay.d.ts +6 -4
  54. package/dist/esm/dnd/overlay.js +108 -28
  55. package/dist/esm/dockview/components/titlebar/tabsContainer.js +4 -2
  56. package/dist/esm/dockview/dockviewComponent.d.ts +20 -17
  57. package/dist/esm/dockview/dockviewComponent.js +93 -46
  58. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +3 -12
  59. package/dist/esm/dockview/options.d.ts +10 -6
  60. package/dist/esm/dockview/options.js +1 -0
  61. package/dist/esm/dom.d.ts +1 -0
  62. package/dist/esm/dom.js +3 -0
  63. package/dist/esm/gridview/baseComponentGridview.d.ts +3 -0
  64. package/dist/esm/gridview/baseComponentGridview.js +6 -2
  65. package/dist/esm/gridview/branchNode.d.ts +7 -3
  66. package/dist/esm/gridview/branchNode.js +19 -7
  67. package/dist/esm/gridview/gridview.d.ts +7 -1
  68. package/dist/esm/gridview/gridview.js +27 -8
  69. package/dist/esm/gridview/gridviewPanel.d.ts +1 -0
  70. package/dist/esm/gridview/gridviewPanel.js +3 -0
  71. package/dist/esm/math.js +5 -1
  72. package/dist/esm/splitview/splitview.d.ts +13 -0
  73. package/dist/esm/splitview/splitview.js +38 -12
  74. package/dist/esm/types.d.ts +23 -0
  75. package/dist/styles/dockview.css +0 -13
  76. package/package.json +1 -1
@@ -44,6 +44,7 @@ export declare abstract class GridviewPanel<T extends GridviewPanelApiImpl = Gri
44
44
  get maximumHeight(): number;
45
45
  get maximumWidth(): number;
46
46
  get isActive(): boolean;
47
+ get isVisible(): boolean;
47
48
  constructor(id: string, component: string, options?: {
48
49
  minimumWidth?: number;
49
50
  maximumWidth?: number;
@@ -51,6 +51,9 @@ export class GridviewPanel extends BasePanelView {
51
51
  get isActive() {
52
52
  return this.api.isActive;
53
53
  }
54
+ get isVisible() {
55
+ return this.api.isVisible;
56
+ }
54
57
  constructor(id, component, options, api) {
55
58
  super(id, component, api !== null && api !== void 0 ? api : new GridviewPanelApiImpl(id, component));
56
59
  this._evaluatedMinimumWidth = 0;
package/dist/esm/math.js CHANGED
@@ -1,6 +1,10 @@
1
1
  export const clamp = (value, min, max) => {
2
2
  if (min > max) {
3
- throw new Error(`${min} > ${max} is an invalid condition`);
3
+ /**
4
+ * caveat: an error should be thrown here if this was a proper `clamp` function but we need to handle
5
+ * cases where `min` > `max` and in those cases return `min`.
6
+ */
7
+ return min;
4
8
  }
5
9
  return Math.min(max, Math.max(value, min));
6
10
  };
@@ -18,6 +18,7 @@ export interface SplitViewOptions {
18
18
  readonly descriptor?: ISplitViewDescriptor;
19
19
  readonly proportionalLayout?: boolean;
20
20
  readonly styles?: ISplitviewStyles;
21
+ readonly margin?: number;
21
22
  }
22
23
  export declare enum LayoutPriority {
23
24
  Low = "low",// view is offered space last
@@ -80,6 +81,7 @@ export declare class Splitview {
80
81
  private _startSnappingEnabled;
81
82
  private _endSnappingEnabled;
82
83
  private _disabled;
84
+ private _margin;
83
85
  private readonly _onDidSashEnd;
84
86
  readonly onDidSashEnd: Event<void>;
85
87
  private readonly _onDidAddView;
@@ -103,6 +105,8 @@ export declare class Splitview {
103
105
  set endSnappingEnabled(endSnappingEnabled: boolean);
104
106
  get disabled(): boolean;
105
107
  set disabled(value: boolean);
108
+ get margin(): number;
109
+ set margin(value: number);
106
110
  constructor(container: HTMLElement, options: SplitViewOptions);
107
111
  style(styles?: ISplitviewStyles): void;
108
112
  isViewVisible(index: number): boolean;
@@ -120,6 +124,15 @@ export declare class Splitview {
120
124
  private relayout;
121
125
  private distributeEmptySpace;
122
126
  private saveProportions;
127
+ /**
128
+ * Margin explain:
129
+ *
130
+ * For `n` views in a splitview there will be `n-1` margins `m`.
131
+ *
132
+ * To fit the margins each view must reduce in size by `(m * (n - 1)) / n`.
133
+ *
134
+ * For each view `i` the offet must be adjusted by `m * i/(n - 1)`.
135
+ */
123
136
  private layoutViews;
124
137
  private findFirstSnapIndex;
125
138
  private updateSashEnablement;
@@ -107,7 +107,14 @@ export class Splitview {
107
107
  this._disabled = value;
108
108
  toggleClass(this.element, 'dv-splitview-disabled', value);
109
109
  }
110
+ get margin() {
111
+ return this._margin;
112
+ }
113
+ set margin(value) {
114
+ this._margin = value;
115
+ }
110
116
  constructor(container, options) {
117
+ var _a;
111
118
  this.container = container;
112
119
  this.viewItems = [];
113
120
  this.sashes = [];
@@ -118,6 +125,7 @@ export class Splitview {
118
125
  this._startSnappingEnabled = true;
119
126
  this._endSnappingEnabled = true;
120
127
  this._disabled = false;
128
+ this._margin = 0;
121
129
  this._onDidSashEnd = new Emitter();
122
130
  this.onDidSashEnd = this._onDidSashEnd.event;
123
131
  this._onDidAddView = new Emitter();
@@ -206,6 +214,7 @@ export class Splitview {
206
214
  };
207
215
  this._orientation = options.orientation;
208
216
  this.element = this.createContainer();
217
+ this.margin = (_a = options.margin) !== null && _a !== void 0 ? _a : 0;
209
218
  this.proportionalLayout =
210
219
  options.proportionalLayout === undefined
211
220
  ? true
@@ -260,9 +269,7 @@ export class Splitview {
260
269
  if (index < 0 || index >= this.viewItems.length) {
261
270
  throw new Error('Index out of bounds');
262
271
  }
263
- toggleClass(this.container, 'visible', visible);
264
272
  const viewItem = this.viewItems[index];
265
- toggleClass(this.container, 'visible', visible);
266
273
  viewItem.setVisible(visible, viewItem.size);
267
274
  this.distributeEmptySpace(index);
268
275
  this.layoutViews();
@@ -574,15 +581,29 @@ export class Splitview {
574
581
  this._proportions = this.viewItems.map((i) => i.visible ? i.size / this._contentSize : undefined);
575
582
  }
576
583
  }
584
+ /**
585
+ * Margin explain:
586
+ *
587
+ * For `n` views in a splitview there will be `n-1` margins `m`.
588
+ *
589
+ * To fit the margins each view must reduce in size by `(m * (n - 1)) / n`.
590
+ *
591
+ * For each view `i` the offet must be adjusted by `m * i/(n - 1)`.
592
+ */
577
593
  layoutViews() {
578
594
  this._contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
579
- let sum = 0;
580
- const x = [];
581
595
  this.updateSashEnablement();
596
+ if (this.viewItems.length === 0) {
597
+ return;
598
+ }
599
+ const sashCount = this.viewItems.length - 1;
600
+ const marginReducedSize = (this.margin * sashCount) / this.viewItems.length;
601
+ let totalLeftOffset = 0;
602
+ const viewLeftOffsets = [];
582
603
  for (let i = 0; i < this.viewItems.length - 1; i++) {
583
- sum += this.viewItems[i].size;
584
- x.push(sum);
585
- const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
604
+ totalLeftOffset += this.viewItems[i].size;
605
+ viewLeftOffsets.push(totalLeftOffset);
606
+ const offset = Math.min(Math.max(0, totalLeftOffset - 2), this.size - this.margin);
586
607
  if (this._orientation === Orientation.HORIZONTAL) {
587
608
  this.sashes[i].container.style.left = `${offset}px`;
588
609
  this.sashes[i].container.style.top = `0px`;
@@ -593,19 +614,24 @@ export class Splitview {
593
614
  }
594
615
  }
595
616
  this.viewItems.forEach((view, i) => {
617
+ const size = view.size - marginReducedSize;
618
+ const offset = i === 0
619
+ ? 0
620
+ : viewLeftOffsets[i - 1] +
621
+ (i / sashCount) * marginReducedSize;
596
622
  if (this._orientation === Orientation.HORIZONTAL) {
597
- view.container.style.width = `${view.size}px`;
598
- view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
623
+ view.container.style.width = `${size}px`;
624
+ view.container.style.left = `${offset}px`;
599
625
  view.container.style.top = '';
600
626
  view.container.style.height = '';
601
627
  }
602
628
  if (this._orientation === Orientation.VERTICAL) {
603
- view.container.style.height = `${view.size}px`;
604
- view.container.style.top = i == 0 ? '0px' : `${x[i - 1]}px`;
629
+ view.container.style.height = `${size}px`;
630
+ view.container.style.top = `${offset}px`;
605
631
  view.container.style.width = '';
606
632
  view.container.style.left = '';
607
633
  }
608
- view.view.layout(view.size, this._orthogonalSize);
634
+ view.view.layout(view.size - marginReducedSize, this._orthogonalSize);
609
635
  });
610
636
  }
611
637
  findFirstSnapIndex(indexes) {
@@ -6,3 +6,26 @@ export interface Box {
6
6
  height: number;
7
7
  width: number;
8
8
  }
9
+ type TopLeft = {
10
+ top: number;
11
+ left: number;
12
+ };
13
+ type TopRight = {
14
+ top: number;
15
+ right: number;
16
+ };
17
+ type BottomLeft = {
18
+ bottom: number;
19
+ left: number;
20
+ };
21
+ type BottomRight = {
22
+ bottom: number;
23
+ right: number;
24
+ };
25
+ type AnchorPosition = TopLeft | TopRight | BottomLeft | BottomRight;
26
+ type Size = {
27
+ width: number;
28
+ height: number;
29
+ };
30
+ export type AnchoredBox = Size & AnchorPosition;
31
+ export {};
@@ -210,7 +210,6 @@
210
210
  --dv-tabs-container-scrollbar-color: #888;
211
211
  --dv-icon-hover-background-color: rgba(90, 93, 94, 0.31);
212
212
  --dv-floating-box-shadow: 8px 8px 8px 0px rgba(83, 89, 93, 0.5);
213
- --dv-group-gap-size: 3px;
214
213
  --dv-group-view-background-color: #ebeced;
215
214
  --dv-tabs-and-actions-container-background-color: #fcfcfc;
216
215
  --dv-activegroup-visiblepanel-tab-background-color: #f0f1f2;
@@ -438,18 +437,6 @@
438
437
  .dv-dockview .dv-overlay-render-container {
439
438
  position: relative;
440
439
  }
441
- .dv-dockview .split-view-container.horizontal > .view-container > .view:not(:last-child) .groupview {
442
- border-right: var(--dv-group-gap-size) solid transparent;
443
- }
444
- .dv-dockview .split-view-container.horizontal > .view-container > .view:not(:first-child) .groupview {
445
- border-left: var(--dv-group-gap-size) solid transparent;
446
- }
447
- .dv-dockview .split-view-container.vertical > .view-container > .view:not(:last-child) .groupview {
448
- border-bottom: var(--dv-group-gap-size) solid transparent;
449
- }
450
- .dv-dockview .split-view-container.vertical > .view-container > .view:not(:first-child) .groupview {
451
- border-top: var(--dv-group-gap-size) solid transparent;
452
- }
453
440
 
454
441
  .groupview.active-group > .tabs-and-actions-container > .tabs-container > .tab.active-tab {
455
442
  background-color: var(--dv-activegroup-visiblepanel-tab-background-color);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dockview-core",
3
- "version": "1.14.2",
3
+ "version": "1.15.0",
4
4
  "description": "Zero dependency layout manager supporting tabs, grids and splitviews",
5
5
  "keywords": [
6
6
  "splitview",