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.
@@ -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
  */
@@ -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
  }
@@ -9886,8 +9874,21 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
9886
9874
  const CloseButton = () => (React.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
9887
9875
  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" })));
9888
9876
 
9877
+ function useTitle(api) {
9878
+ const [title, setTitle] = React.useState(api.title);
9879
+ React.useEffect(() => {
9880
+ const disposable = api.onDidTitleChange((event) => {
9881
+ setTitle(event.title);
9882
+ });
9883
+ return () => {
9884
+ disposable.dispose();
9885
+ };
9886
+ }, [api]);
9887
+ return title;
9888
+ }
9889
9889
  const DockviewDefaultTab = (_a) => {
9890
9890
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9891
+ const title = useTitle(api);
9891
9892
  const onClose = React.useCallback((event) => {
9892
9893
  event.preventDefault();
9893
9894
  if (closeActionOverride) {
@@ -9910,7 +9911,7 @@ const DockviewDefaultTab = (_a) => {
9910
9911
  }
9911
9912
  }, [api, rest.onClick]);
9912
9913
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9913
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9914
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9914
9915
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9915
9916
  React.createElement(CloseButton, null)))));
9916
9917
  };