dockview 1.14.1 → 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.
@@ -21,6 +21,22 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  }
22
22
  return t;
23
23
  };
24
+ var __read = (this && this.__read) || function (o, n) {
25
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26
+ if (!m) return o;
27
+ var i = m.call(o), r, ar = [], e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ }
31
+ catch (error) { e = { error: error }; }
32
+ finally {
33
+ try {
34
+ if (r && !r.done && (m = i["return"])) m.call(i);
35
+ }
36
+ finally { if (e) throw e.error; }
37
+ }
38
+ return ar;
39
+ };
24
40
  var __importDefault = (this && this.__importDefault) || function (mod) {
25
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
42
  };
@@ -28,8 +44,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
28
44
  exports.DockviewDefaultTab = void 0;
29
45
  var react_1 = __importDefault(require("react"));
30
46
  var svg_1 = require("../svg");
47
+ function useTitle(api) {
48
+ var _a = __read(react_1.default.useState(api.title), 2), title = _a[0], setTitle = _a[1];
49
+ react_1.default.useEffect(function () {
50
+ var disposable = api.onDidTitleChange(function (event) {
51
+ setTitle(event.title);
52
+ });
53
+ return function () {
54
+ disposable.dispose();
55
+ };
56
+ }, [api]);
57
+ return title;
58
+ }
31
59
  var DockviewDefaultTab = function (_a) {
32
60
  var api = _a.api, _containerApi = _a.containerApi, _params = _a.params, hideClose = _a.hideClose, closeActionOverride = _a.closeActionOverride, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
61
+ var title = useTitle(api);
33
62
  var onClose = react_1.default.useCallback(function (event) {
34
63
  event.preventDefault();
35
64
  if (closeActionOverride) {
@@ -52,7 +81,7 @@ var DockviewDefaultTab = function (_a) {
52
81
  }
53
82
  }, [api, rest.onClick]);
54
83
  return (react_1.default.createElement("div", __assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
55
- react_1.default.createElement("span", { className: "dv-default-tab-content" }, api.title),
84
+ react_1.default.createElement("span", { className: "dv-default-tab-content" }, title),
56
85
  !hideClose && (react_1.default.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
57
86
  react_1.default.createElement(svg_1.CloseButton, null)))));
58
87
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.14.1
3
+ * @version 1.14.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -6207,52 +6207,40 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6207
6207
  }
6208
6208
  constructor() {
6209
6209
  super();
6210
- //
6211
- this.params = {};
6212
6210
  this._element = document.createElement('div');
6213
6211
  this._element.className = 'dv-default-tab';
6214
- //
6215
6212
  this._content = document.createElement('div');
6216
6213
  this._content.className = 'dv-default-tab-content';
6217
6214
  this.action = document.createElement('div');
6218
6215
  this.action.className = 'dv-default-tab-action';
6219
6216
  this.action.appendChild(createCloseButton());
6220
- //
6221
6217
  this._element.appendChild(this._content);
6222
6218
  this._element.appendChild(this.action);
6223
- //
6224
6219
  this.addDisposables(addDisposableListener(this.action, 'mousedown', (ev) => {
6225
6220
  ev.preventDefault();
6226
6221
  }));
6227
6222
  this.render();
6228
6223
  }
6229
- update(event) {
6230
- this.params = Object.assign(Object.assign({}, this.params), event.params);
6231
- this.render();
6232
- }
6233
- focus() {
6234
- //noop
6235
- }
6236
6224
  init(params) {
6237
- this.params = params;
6238
- this._content.textContent = params.title;
6239
- addDisposableListener(this.action, 'click', (ev) => {
6240
- ev.preventDefault(); //
6241
- this.params.api.close();
6242
- });
6243
- }
6244
- onGroupChange(_group) {
6245
- this.render();
6246
- }
6247
- onPanelVisibleChange(_isPanelVisible) {
6225
+ this._title = params.title;
6226
+ this.addDisposables(params.api.onDidTitleChange((event) => {
6227
+ this._title = event.title;
6228
+ this.render();
6229
+ }), addDisposableListener(this.action, 'mousedown', (ev) => {
6230
+ ev.preventDefault();
6231
+ }), addDisposableListener(this.action, 'click', (ev) => {
6232
+ if (ev.defaultPrevented) {
6233
+ return;
6234
+ }
6235
+ ev.preventDefault();
6236
+ params.api.close();
6237
+ }));
6248
6238
  this.render();
6249
6239
  }
6250
- layout(_width, _height) {
6251
- // noop
6252
- }
6253
6240
  render() {
6254
- if (this._content.textContent !== this.params.title) {
6255
- this._content.textContent = this.params.title;
6241
+ var _a;
6242
+ if (this._content.textContent !== this._title) {
6243
+ this._content.textContent = (_a = this._title) !== null && _a !== void 0 ? _a : '';
6256
6244
  }
6257
6245
  }
6258
6246
  }
@@ -9885,8 +9873,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9885
9873
  const CloseButton = () => (React.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
9886
9874
  React.createElement("path", { d: "M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z" })));
9887
9875
 
9876
+ function useTitle(api) {
9877
+ const [title, setTitle] = React.useState(api.title);
9878
+ React.useEffect(() => {
9879
+ const disposable = api.onDidTitleChange((event) => {
9880
+ setTitle(event.title);
9881
+ });
9882
+ return () => {
9883
+ disposable.dispose();
9884
+ };
9885
+ }, [api]);
9886
+ return title;
9887
+ }
9888
9888
  const DockviewDefaultTab = (_a) => {
9889
9889
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9890
+ const title = useTitle(api);
9890
9891
  const onClose = React.useCallback((event) => {
9891
9892
  event.preventDefault();
9892
9893
  if (closeActionOverride) {
@@ -9909,7 +9910,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9909
9910
  }
9910
9911
  }, [api, rest.onClick]);
9911
9912
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9912
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9913
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9913
9914
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9914
9915
  React.createElement(CloseButton, null)))));
9915
9916
  };