dockview-react 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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
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
  }
@@ -9862,8 +9850,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9862
9850
  }
9863
9851
  return t;
9864
9852
  };
9853
+ function useTitle(api) {
9854
+ const [title, setTitle] = React.useState(api.title);
9855
+ React.useEffect(() => {
9856
+ const disposable = api.onDidTitleChange((event) => {
9857
+ setTitle(event.title);
9858
+ });
9859
+ return () => {
9860
+ disposable.dispose();
9861
+ };
9862
+ }, [api]);
9863
+ return title;
9864
+ }
9865
9865
  const DockviewDefaultTab = (_a) => {
9866
9866
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9867
+ const title = useTitle(api);
9867
9868
  const onClose = React.useCallback((event) => {
9868
9869
  event.preventDefault();
9869
9870
  if (closeActionOverride) {
@@ -9886,7 +9887,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9886
9887
  }
9887
9888
  }, [api, rest.onClick]);
9888
9889
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9889
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9890
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9890
9891
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9891
9892
  React.createElement(CloseButton, null)))));
9892
9893
  };