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
  */
@@ -6177,52 +6177,40 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6177
6177
  }
6178
6178
  constructor() {
6179
6179
  super();
6180
- //
6181
- this.params = {};
6182
6180
  this._element = document.createElement('div');
6183
6181
  this._element.className = 'dv-default-tab';
6184
- //
6185
6182
  this._content = document.createElement('div');
6186
6183
  this._content.className = 'dv-default-tab-content';
6187
6184
  this.action = document.createElement('div');
6188
6185
  this.action.className = 'dv-default-tab-action';
6189
6186
  this.action.appendChild(createCloseButton());
6190
- //
6191
6187
  this._element.appendChild(this._content);
6192
6188
  this._element.appendChild(this.action);
6193
- //
6194
6189
  this.addDisposables(addDisposableListener(this.action, 'mousedown', (ev) => {
6195
6190
  ev.preventDefault();
6196
6191
  }));
6197
6192
  this.render();
6198
6193
  }
6199
- update(event) {
6200
- this.params = Object.assign(Object.assign({}, this.params), event.params);
6201
- this.render();
6202
- }
6203
- focus() {
6204
- //noop
6205
- }
6206
6194
  init(params) {
6207
- this.params = params;
6208
- this._content.textContent = params.title;
6209
- addDisposableListener(this.action, 'click', (ev) => {
6210
- ev.preventDefault(); //
6211
- this.params.api.close();
6212
- });
6213
- }
6214
- onGroupChange(_group) {
6215
- this.render();
6216
- }
6217
- onPanelVisibleChange(_isPanelVisible) {
6195
+ this._title = params.title;
6196
+ this.addDisposables(params.api.onDidTitleChange((event) => {
6197
+ this._title = event.title;
6198
+ this.render();
6199
+ }), addDisposableListener(this.action, 'mousedown', (ev) => {
6200
+ ev.preventDefault();
6201
+ }), addDisposableListener(this.action, 'click', (ev) => {
6202
+ if (ev.defaultPrevented) {
6203
+ return;
6204
+ }
6205
+ ev.preventDefault();
6206
+ params.api.close();
6207
+ }));
6218
6208
  this.render();
6219
6209
  }
6220
- layout(_width, _height) {
6221
- // noop
6222
- }
6223
6210
  render() {
6224
- if (this._content.textContent !== this.params.title) {
6225
- this._content.textContent = this.params.title;
6211
+ var _a;
6212
+ if (this._content.textContent !== this._title) {
6213
+ this._content.textContent = (_a = this._title) !== null && _a !== void 0 ? _a : '';
6226
6214
  }
6227
6215
  }
6228
6216
  }
@@ -9832,8 +9820,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9832
9820
  }
9833
9821
  return t;
9834
9822
  };
9823
+ function useTitle(api) {
9824
+ const [title, setTitle] = React.useState(api.title);
9825
+ React.useEffect(() => {
9826
+ const disposable = api.onDidTitleChange((event) => {
9827
+ setTitle(event.title);
9828
+ });
9829
+ return () => {
9830
+ disposable.dispose();
9831
+ };
9832
+ }, [api]);
9833
+ return title;
9834
+ }
9835
9835
  const DockviewDefaultTab = (_a) => {
9836
9836
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9837
+ const title = useTitle(api);
9837
9838
  const onClose = React.useCallback((event) => {
9838
9839
  event.preventDefault();
9839
9840
  if (closeActionOverride) {
@@ -9856,7 +9857,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9856
9857
  }
9857
9858
  }, [api, rest.onClick]);
9858
9859
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9859
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9860
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9860
9861
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9861
9862
  React.createElement(CloseButton, null)))));
9862
9863
  };