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
  */
@@ -6208,52 +6208,40 @@ class DefaultTab extends CompositeDisposable {
6208
6208
  }
6209
6209
  constructor() {
6210
6210
  super();
6211
- //
6212
- this.params = {};
6213
6211
  this._element = document.createElement('div');
6214
6212
  this._element.className = 'dv-default-tab';
6215
- //
6216
6213
  this._content = document.createElement('div');
6217
6214
  this._content.className = 'dv-default-tab-content';
6218
6215
  this.action = document.createElement('div');
6219
6216
  this.action.className = 'dv-default-tab-action';
6220
6217
  this.action.appendChild(createCloseButton());
6221
- //
6222
6218
  this._element.appendChild(this._content);
6223
6219
  this._element.appendChild(this.action);
6224
- //
6225
6220
  this.addDisposables(addDisposableListener(this.action, 'mousedown', (ev) => {
6226
6221
  ev.preventDefault();
6227
6222
  }));
6228
6223
  this.render();
6229
6224
  }
6230
- update(event) {
6231
- this.params = Object.assign(Object.assign({}, this.params), event.params);
6232
- this.render();
6233
- }
6234
- focus() {
6235
- //noop
6236
- }
6237
6225
  init(params) {
6238
- this.params = params;
6239
- this._content.textContent = params.title;
6240
- addDisposableListener(this.action, 'click', (ev) => {
6241
- ev.preventDefault(); //
6242
- this.params.api.close();
6243
- });
6244
- }
6245
- onGroupChange(_group) {
6246
- this.render();
6247
- }
6248
- onPanelVisibleChange(_isPanelVisible) {
6226
+ this._title = params.title;
6227
+ this.addDisposables(params.api.onDidTitleChange((event) => {
6228
+ this._title = event.title;
6229
+ this.render();
6230
+ }), addDisposableListener(this.action, 'mousedown', (ev) => {
6231
+ ev.preventDefault();
6232
+ }), addDisposableListener(this.action, 'click', (ev) => {
6233
+ if (ev.defaultPrevented) {
6234
+ return;
6235
+ }
6236
+ ev.preventDefault();
6237
+ params.api.close();
6238
+ }));
6249
6239
  this.render();
6250
6240
  }
6251
- layout(_width, _height) {
6252
- // noop
6253
- }
6254
6241
  render() {
6255
- if (this._content.textContent !== this.params.title) {
6256
- this._content.textContent = this.params.title;
6242
+ var _a;
6243
+ if (this._content.textContent !== this._title) {
6244
+ this._content.textContent = (_a = this._title) !== null && _a !== void 0 ? _a : '';
6257
6245
  }
6258
6246
  }
6259
6247
  }
@@ -9863,8 +9851,21 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
9863
9851
  }
9864
9852
  return t;
9865
9853
  };
9854
+ function useTitle(api) {
9855
+ const [title, setTitle] = React.useState(api.title);
9856
+ React.useEffect(() => {
9857
+ const disposable = api.onDidTitleChange((event) => {
9858
+ setTitle(event.title);
9859
+ });
9860
+ return () => {
9861
+ disposable.dispose();
9862
+ };
9863
+ }, [api]);
9864
+ return title;
9865
+ }
9866
9866
  const DockviewDefaultTab = (_a) => {
9867
9867
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9868
+ const title = useTitle(api);
9868
9869
  const onClose = React.useCallback((event) => {
9869
9870
  event.preventDefault();
9870
9871
  if (closeActionOverride) {
@@ -9887,7 +9888,7 @@ const DockviewDefaultTab = (_a) => {
9887
9888
  }
9888
9889
  }, [api, rest.onClick]);
9889
9890
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9890
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9891
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9891
9892
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9892
9893
  React.createElement(CloseButton, null)))));
9893
9894
  };