dockview-core 1.14.0 → 1.14.2

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 (43) hide show
  1. package/README.md +1 -21
  2. package/dist/cjs/dockview/components/tab/defaultTab.d.ts +1 -8
  3. package/dist/cjs/dockview/components/tab/defaultTab.js +16 -39
  4. package/dist/cjs/dockview/dockviewComponent.js +0 -60
  5. package/dist/cjs/dockview/options.d.ts +1 -1
  6. package/dist/cjs/dockview/types.d.ts +5 -10
  7. package/dist/cjs/dockview/validate.d.ts +0 -0
  8. package/dist/cjs/dockview/validate.js +76 -0
  9. package/dist/cjs/index.d.ts +4 -3
  10. package/dist/cjs/index.js +5 -3
  11. package/dist/dockview-core.amd.js +31 -43
  12. package/dist/dockview-core.amd.js.map +1 -1
  13. package/dist/dockview-core.amd.min.js +2 -2
  14. package/dist/dockview-core.amd.min.js.map +1 -1
  15. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  16. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  17. package/dist/dockview-core.amd.noStyle.js +30 -42
  18. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  19. package/dist/dockview-core.cjs.js +31 -43
  20. package/dist/dockview-core.cjs.js.map +1 -1
  21. package/dist/dockview-core.esm.js +19 -31
  22. package/dist/dockview-core.esm.js.map +1 -1
  23. package/dist/dockview-core.esm.min.js +2 -2
  24. package/dist/dockview-core.esm.min.js.map +1 -1
  25. package/dist/dockview-core.js +31 -43
  26. package/dist/dockview-core.js.map +1 -1
  27. package/dist/dockview-core.min.js +2 -2
  28. package/dist/dockview-core.min.js.map +1 -1
  29. package/dist/dockview-core.min.noStyle.js +2 -2
  30. package/dist/dockview-core.min.noStyle.js.map +1 -1
  31. package/dist/dockview-core.noStyle.js +30 -42
  32. package/dist/dockview-core.noStyle.js.map +1 -1
  33. package/dist/esm/dockview/components/tab/defaultTab.d.ts +1 -8
  34. package/dist/esm/dockview/components/tab/defaultTab.js +16 -28
  35. package/dist/esm/dockview/dockviewComponent.js +0 -60
  36. package/dist/esm/dockview/options.d.ts +1 -1
  37. package/dist/esm/dockview/types.d.ts +5 -10
  38. package/dist/esm/dockview/validate.d.ts +0 -0
  39. package/dist/esm/dockview/validate.js +76 -0
  40. package/dist/esm/index.d.ts +4 -3
  41. package/dist/esm/index.js +4 -3
  42. package/dist/styles/dockview.css +4 -4
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <div align="center">
2
2
  <h1>dockview</h1>
3
3
 
4
- <p>Zero dependency layout manager supporting tabs, groups, grids and splitviews written in TypeScript</p>
4
+ <p>Zero dependency layout manager supporting tabs, groups, grids and splitviews. Supports React, Vue and Vanilla TypeScript</p>
5
5
 
6
6
  </div>
7
7
 
@@ -36,23 +36,3 @@ Please see the website: https://dockview.dev
36
36
  - Security at mind - verifed publishing and builds through GitHub Actions
37
37
 
38
38
  Want to verify our builds? Go [here](https://www.npmjs.com/package/dockview#Provenance).
39
-
40
- ## Quick start
41
-
42
- Dockview has a peer dependency on `react >= 16.8.0` and `react-dom >= 16.8.0`. You can install dockview from [npm](https://www.npmjs.com/package/dockview-core).
43
-
44
- ```
45
- npm install --save dockview-core
46
- ```
47
-
48
- Within your project you must import or reference the stylesheet at `dockview-core/dist/styles/dockview.css` and attach a theme.
49
-
50
- ```css
51
- @import '~dockview-core/dist/styles/dockview.css';
52
- ```
53
-
54
- You should also attach a dockview theme to an element containing your components. For example:
55
-
56
- ```html
57
- <body classname="dockview-theme-dark"></body>
58
- ```
@@ -1,19 +1,12 @@
1
1
  import { CompositeDisposable } from '../../../lifecycle';
2
2
  import { ITabRenderer, GroupPanelPartInitParameters } from '../../types';
3
- import { PanelUpdateEvent } from '../../../panel/types';
4
- import { DockviewGroupPanel } from '../../dockviewGroupPanel';
5
3
  export declare class DefaultTab extends CompositeDisposable implements ITabRenderer {
6
4
  private _element;
7
5
  private _content;
8
6
  private action;
9
- private params;
7
+ private _title;
10
8
  get element(): HTMLElement;
11
9
  constructor();
12
- update(event: PanelUpdateEvent): void;
13
- focus(): void;
14
10
  init(params: GroupPanelPartInitParameters): void;
15
- onGroupChange(_group: DockviewGroupPanel): void;
16
- onPanelVisibleChange(_isPanelVisible: boolean): void;
17
- layout(_width: number, _height: number): void;
18
11
  private render;
19
12
  }
@@ -14,17 +14,6 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
17
  Object.defineProperty(exports, "__esModule", { value: true });
29
18
  exports.DefaultTab = void 0;
30
19
  var lifecycle_1 = require("../../../lifecycle");
@@ -34,20 +23,15 @@ var DefaultTab = /** @class */ (function (_super) {
34
23
  __extends(DefaultTab, _super);
35
24
  function DefaultTab() {
36
25
  var _this = _super.call(this) || this;
37
- //
38
- _this.params = {};
39
26
  _this._element = document.createElement('div');
40
27
  _this._element.className = 'dv-default-tab';
41
- //
42
28
  _this._content = document.createElement('div');
43
29
  _this._content.className = 'dv-default-tab-content';
44
30
  _this.action = document.createElement('div');
45
31
  _this.action.className = 'dv-default-tab-action';
46
32
  _this.action.appendChild((0, svg_1.createCloseButton)());
47
- //
48
33
  _this._element.appendChild(_this._content);
49
34
  _this._element.appendChild(_this.action);
50
- //
51
35
  _this.addDisposables((0, events_1.addDisposableListener)(_this.action, 'mousedown', function (ev) {
52
36
  ev.preventDefault();
53
37
  }));
@@ -61,34 +45,27 @@ var DefaultTab = /** @class */ (function (_super) {
61
45
  enumerable: false,
62
46
  configurable: true
63
47
  });
64
- DefaultTab.prototype.update = function (event) {
65
- this.params = __assign(__assign({}, this.params), event.params);
66
- this.render();
67
- };
68
- DefaultTab.prototype.focus = function () {
69
- //noop
70
- };
71
48
  DefaultTab.prototype.init = function (params) {
72
49
  var _this = this;
73
- this.params = params;
74
- this._content.textContent = params.title;
75
- (0, events_1.addDisposableListener)(this.action, 'click', function (ev) {
76
- ev.preventDefault(); //
77
- _this.params.api.close();
78
- });
79
- };
80
- DefaultTab.prototype.onGroupChange = function (_group) {
81
- this.render();
82
- };
83
- DefaultTab.prototype.onPanelVisibleChange = function (_isPanelVisible) {
50
+ this._title = params.title;
51
+ this.addDisposables(params.api.onDidTitleChange(function (event) {
52
+ _this._title = event.title;
53
+ _this.render();
54
+ }), (0, events_1.addDisposableListener)(this.action, 'mousedown', function (ev) {
55
+ ev.preventDefault();
56
+ }), (0, events_1.addDisposableListener)(this.action, 'click', function (ev) {
57
+ if (ev.defaultPrevented) {
58
+ return;
59
+ }
60
+ ev.preventDefault();
61
+ params.api.close();
62
+ }));
84
63
  this.render();
85
64
  };
86
- DefaultTab.prototype.layout = function (_width, _height) {
87
- // noop
88
- };
89
65
  DefaultTab.prototype.render = function () {
90
- if (this._content.textContent !== this.params.title) {
91
- this._content.textContent = this.params.title;
66
+ var _a;
67
+ if (this._content.textContent !== this._title) {
68
+ this._content.textContent = (_a = this._title) !== null && _a !== void 0 ? _a : '';
92
69
  }
93
70
  };
94
71
  return DefaultTab;
@@ -125,66 +125,6 @@ function getDockviewTheme(element) {
125
125
  }
126
126
  return theme;
127
127
  }
128
- function typeValidate3(data, path) {
129
- if (typeof data.id !== 'string') {
130
- throw new Error("".concat(path, ".id must be a string"));
131
- }
132
- if (typeof data.activeView !== 'string' ||
133
- typeof data.activeView !== 'undefined') {
134
- throw new Error("".concat(path, ".activeView must be a string of undefined"));
135
- }
136
- }
137
- function typeValidate2(data, path) {
138
- if (typeof data.size !== 'number' && typeof data.size !== 'undefined') {
139
- throw new Error("".concat(path, ".size must be a number or undefined"));
140
- }
141
- if (typeof data.visible !== 'boolean' &&
142
- typeof data.visible !== 'undefined') {
143
- throw new Error("".concat(path, ".visible must be a boolean or undefined"));
144
- }
145
- if (data.type === 'leaf') {
146
- if (typeof data.data !== 'object' ||
147
- data.data === null ||
148
- Array.isArray(data.data)) {
149
- throw new Error('object must be a non-null object');
150
- }
151
- typeValidate3(data.data, "".concat(path, ".data"));
152
- }
153
- else if (data.type === 'branch') {
154
- if (!Array.isArray(data.data)) {
155
- throw new Error("".concat(path, ".data must be an array"));
156
- }
157
- }
158
- else {
159
- throw new Error("".concat(path, ".type must be onew of {'branch', 'leaf'}"));
160
- }
161
- }
162
- function typeValidate(data) {
163
- if (typeof data !== 'object' || data === null) {
164
- throw new Error('object must be a non-null object');
165
- }
166
- var grid = data.grid, panels = data.panels, activeGroup = data.activeGroup, floatingGroups = data.floatingGroups;
167
- if (typeof grid !== 'object' || grid === null) {
168
- throw new Error("'.grid' must be a non-null object");
169
- }
170
- if (typeof grid.height !== 'number') {
171
- throw new Error("'.grid.height' must be a number");
172
- }
173
- if (typeof grid.width !== 'number') {
174
- throw new Error("'.grid.width' must be a number");
175
- }
176
- if (typeof grid.root !== 'object' || grid.root === null) {
177
- throw new Error("'.grid.root' must be a non-null object");
178
- }
179
- if (grid.root.type !== 'branch') {
180
- throw new Error(".grid.root.type must be of type 'branch'");
181
- }
182
- if (grid.orientation !== splitview_1.Orientation.HORIZONTAL &&
183
- grid.orientation !== splitview_1.Orientation.VERTICAL) {
184
- throw new Error("'.grid.width' must be one of {".concat(splitview_1.Orientation.HORIZONTAL, ", ").concat(splitview_1.Orientation.VERTICAL, "}"));
185
- }
186
- typeValidate2(grid.root, '.grid.root');
187
- }
188
128
  var DockviewComponent = /** @class */ (function (_super) {
189
129
  __extends(DockviewComponent, _super);
190
130
  function DockviewComponent(options) {
@@ -109,7 +109,7 @@ type AddPanelFloatingGroupUnion = {
109
109
  position: never;
110
110
  };
111
111
  type AddPanelPositionUnion = {
112
- floating: false | never;
112
+ floating: false;
113
113
  position: AddPanelPositionOptions;
114
114
  };
115
115
  type AddPanelOptionsUnion = AddPanelFloatingGroupUnion | AddPanelPositionUnion;
@@ -1,4 +1,3 @@
1
- import { IDockviewComponent } from './dockviewComponent';
2
1
  import { DockviewPanelApi } from '../api/dockviewPanelApi';
3
2
  import { PanelInitParameters, IPanel } from '../panel/types';
4
3
  import { DockviewApi } from '../api/component.api';
@@ -16,25 +15,20 @@ export interface WatermarkRendererInitParameters {
16
15
  containerApi: DockviewApi;
17
16
  group?: IDockviewGroupPanel;
18
17
  }
19
- export interface IWatermarkRenderer extends Optional<Omit<IPanel, 'id' | 'init'>, 'dispose' | 'update' | 'layout' | 'toJSON' | 'focus'> {
18
+ type RendererMethodOptionalList = 'dispose' | 'update' | 'layout' | 'toJSON' | 'focus';
19
+ export interface IWatermarkRenderer extends Optional<Omit<IPanel, 'id' | 'init'>, RendererMethodOptionalList> {
20
20
  readonly element: HTMLElement;
21
21
  init: (params: WatermarkRendererInitParameters) => void;
22
22
  updateParentGroup(group: DockviewGroupPanel, visible: boolean): void;
23
23
  }
24
- export interface ITabRenderer extends Optional<Omit<IPanel, 'id'>, 'dispose' | 'update' | 'layout' | 'toJSON' | 'focus'> {
24
+ export interface ITabRenderer extends Optional<Omit<IPanel, 'id'>, RendererMethodOptionalList> {
25
25
  readonly element: HTMLElement;
26
26
  init(parameters: GroupPanelPartInitParameters): void;
27
27
  }
28
- export interface IContentRenderer extends Optional<Omit<IPanel, 'id'>, 'dispose' | 'update' | 'layout' | 'toJSON' | 'focus'> {
28
+ export interface IContentRenderer extends Optional<Omit<IPanel, 'id'>, RendererMethodOptionalList> {
29
29
  readonly element: HTMLElement;
30
30
  init(parameters: GroupPanelPartInitParameters): void;
31
31
  }
32
- export interface WatermarkPartInitParameters {
33
- accessor: IDockviewComponent;
34
- }
35
- export interface WatermarkConstructor {
36
- new (): IWatermarkRenderer;
37
- }
38
32
  export interface IGroupPanelInitParameters extends PanelInitParameters, HeaderPartInitParameters {
39
33
  }
40
34
  export interface GroupviewPanelState {
@@ -47,3 +41,4 @@ export interface GroupviewPanelState {
47
41
  [key: string]: any;
48
42
  };
49
43
  }
44
+ export {};
File without changes
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ // import { SerializedGridObject } from '../gridview/gridview';
3
+ // import { Orientation } from '../splitview/splitview';
4
+ // import { SerializedDockview } from './dockviewComponent';
5
+ // import { GroupPanelViewState } from './dockviewGroupPanelModel';
6
+ // function typeValidate3(data: GroupPanelViewState, path: string): void {
7
+ // if (typeof data.id !== 'string') {
8
+ // throw new Error(`${path}.id must be a string`);
9
+ // }
10
+ // if (
11
+ // typeof data.activeView !== 'string' ||
12
+ // typeof data.activeView !== 'undefined'
13
+ // ) {
14
+ // throw new Error(`${path}.activeView must be a string of undefined`);
15
+ // }
16
+ // }
17
+ // function typeValidate2(
18
+ // data: SerializedGridObject<GroupPanelViewState>,
19
+ // path: string
20
+ // ): void {
21
+ // if (typeof data.size !== 'number' && typeof data.size !== 'undefined') {
22
+ // throw new Error(`${path}.size must be a number or undefined`);
23
+ // }
24
+ // if (
25
+ // typeof data.visible !== 'boolean' &&
26
+ // typeof data.visible !== 'undefined'
27
+ // ) {
28
+ // throw new Error(`${path}.visible must be a boolean or undefined`);
29
+ // }
30
+ // if (data.type === 'leaf') {
31
+ // if (
32
+ // typeof data.data !== 'object' ||
33
+ // data.data === null ||
34
+ // Array.isArray(data.data)
35
+ // ) {
36
+ // throw new Error('object must be a non-null object');
37
+ // }
38
+ // typeValidate3(data.data, `${path}.data`);
39
+ // } else if (data.type === 'branch') {
40
+ // if (!Array.isArray(data.data)) {
41
+ // throw new Error(`${path}.data must be an array`);
42
+ // }
43
+ // } else {
44
+ // throw new Error(`${path}.type must be onew of {'branch', 'leaf'}`);
45
+ // }
46
+ // }
47
+ // function typeValidate(data: SerializedDockview): void {
48
+ // if (typeof data !== 'object' || data === null) {
49
+ // throw new Error('object must be a non-null object');
50
+ // }
51
+ // const { grid, panels, activeGroup, floatingGroups } = data;
52
+ // if (typeof grid !== 'object' || grid === null) {
53
+ // throw new Error("'.grid' must be a non-null object");
54
+ // }
55
+ // if (typeof grid.height !== 'number') {
56
+ // throw new Error("'.grid.height' must be a number");
57
+ // }
58
+ // if (typeof grid.width !== 'number') {
59
+ // throw new Error("'.grid.width' must be a number");
60
+ // }
61
+ // if (typeof grid.root !== 'object' || grid.root === null) {
62
+ // throw new Error("'.grid.root' must be a non-null object");
63
+ // }
64
+ // if (grid.root.type !== 'branch') {
65
+ // throw new Error(".grid.root.type must be of type 'branch'");
66
+ // }
67
+ // if (
68
+ // grid.orientation !== Orientation.HORIZONTAL &&
69
+ // grid.orientation !== Orientation.VERTICAL
70
+ // ) {
71
+ // throw new Error(
72
+ // `'.grid.width' must be one of {${Orientation.HORIZONTAL}, ${Orientation.VERTICAL}}`
73
+ // );
74
+ // }
75
+ // typeValidate2(grid.root, '.grid.root');
76
+ // }
@@ -1,10 +1,11 @@
1
1
  export * from './dnd/dataTransfer';
2
2
  /**
3
- * Events, Emitters and Disposables are very common concepts that most codebases will contain.
4
- * We export them with a 'Dockview' prefix here to prevent accidental use by others.
3
+ * Events, Emitters and Disposables are very common concepts that many codebases will contain, however we need
4
+ * to export them for dockview framework packages to use.
5
+ * To be a good citizen these are exported with a `Dockview` prefix to prevent accidental use by others.
5
6
  */
6
7
  export { Emitter as DockviewEmitter, Event as DockviewEvent } from './events';
7
- export { IDisposable as IDockviewDisposable, MutableDisposable as DockviewMutableDisposable, CompositeDisposable as DockviewCompositeDisposable, } from './lifecycle';
8
+ export { IDisposable as IDockviewDisposable, MutableDisposable as DockviewMutableDisposable, CompositeDisposable as DockviewCompositeDisposable, Disposable as DockviewDisposable, } from './lifecycle';
8
9
  export * from './panel/types';
9
10
  export * from './panel/componentFactory';
10
11
  export * from './splitview/splitview';
package/dist/cjs/index.js CHANGED
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.DockviewApi = exports.GridviewApi = exports.PaneviewApi = exports.SplitviewApi = exports.directionToPosition = exports.positionToDirection = exports.DockviewCompositeDisposable = exports.DockviewMutableDisposable = exports.DockviewEvent = exports.DockviewEmitter = void 0;
17
+ exports.DockviewApi = exports.GridviewApi = exports.PaneviewApi = exports.SplitviewApi = exports.directionToPosition = exports.positionToDirection = exports.DockviewDisposable = exports.DockviewCompositeDisposable = exports.DockviewMutableDisposable = exports.DockviewEvent = exports.DockviewEmitter = void 0;
18
18
  __exportStar(require("./dnd/dataTransfer"), exports);
19
19
  /**
20
- * Events, Emitters and Disposables are very common concepts that most codebases will contain.
21
- * We export them with a 'Dockview' prefix here to prevent accidental use by others.
20
+ * Events, Emitters and Disposables are very common concepts that many codebases will contain, however we need
21
+ * to export them for dockview framework packages to use.
22
+ * To be a good citizen these are exported with a `Dockview` prefix to prevent accidental use by others.
22
23
  */
23
24
  var events_1 = require("./events");
24
25
  Object.defineProperty(exports, "DockviewEmitter", { enumerable: true, get: function () { return events_1.Emitter; } });
@@ -26,6 +27,7 @@ Object.defineProperty(exports, "DockviewEvent", { enumerable: true, get: functio
26
27
  var lifecycle_1 = require("./lifecycle");
27
28
  Object.defineProperty(exports, "DockviewMutableDisposable", { enumerable: true, get: function () { return lifecycle_1.MutableDisposable; } });
28
29
  Object.defineProperty(exports, "DockviewCompositeDisposable", { enumerable: true, get: function () { return lifecycle_1.CompositeDisposable; } });
30
+ Object.defineProperty(exports, "DockviewDisposable", { enumerable: true, get: function () { return lifecycle_1.Disposable; } });
29
31
  __exportStar(require("./panel/types"), exports);
30
32
  __exportStar(require("./panel/componentFactory"), exports);
31
33
  __exportStar(require("./splitview/splitview"), exports);