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