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.
package/dist/dockview.js CHANGED
@@ -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
  */
@@ -6211,52 +6211,40 @@
6211
6211
  }
6212
6212
  constructor() {
6213
6213
  super();
6214
- //
6215
- this.params = {};
6216
6214
  this._element = document.createElement('div');
6217
6215
  this._element.className = 'dv-default-tab';
6218
- //
6219
6216
  this._content = document.createElement('div');
6220
6217
  this._content.className = 'dv-default-tab-content';
6221
6218
  this.action = document.createElement('div');
6222
6219
  this.action.className = 'dv-default-tab-action';
6223
6220
  this.action.appendChild(createCloseButton());
6224
- //
6225
6221
  this._element.appendChild(this._content);
6226
6222
  this._element.appendChild(this.action);
6227
- //
6228
6223
  this.addDisposables(addDisposableListener(this.action, 'mousedown', (ev) => {
6229
6224
  ev.preventDefault();
6230
6225
  }));
6231
6226
  this.render();
6232
6227
  }
6233
- update(event) {
6234
- this.params = Object.assign(Object.assign({}, this.params), event.params);
6235
- this.render();
6236
- }
6237
- focus() {
6238
- //noop
6239
- }
6240
6228
  init(params) {
6241
- this.params = params;
6242
- this._content.textContent = params.title;
6243
- addDisposableListener(this.action, 'click', (ev) => {
6244
- ev.preventDefault(); //
6245
- this.params.api.close();
6246
- });
6247
- }
6248
- onGroupChange(_group) {
6249
- this.render();
6250
- }
6251
- onPanelVisibleChange(_isPanelVisible) {
6229
+ this._title = params.title;
6230
+ this.addDisposables(params.api.onDidTitleChange((event) => {
6231
+ this._title = event.title;
6232
+ this.render();
6233
+ }), addDisposableListener(this.action, 'mousedown', (ev) => {
6234
+ ev.preventDefault();
6235
+ }), addDisposableListener(this.action, 'click', (ev) => {
6236
+ if (ev.defaultPrevented) {
6237
+ return;
6238
+ }
6239
+ ev.preventDefault();
6240
+ params.api.close();
6241
+ }));
6252
6242
  this.render();
6253
6243
  }
6254
- layout(_width, _height) {
6255
- // noop
6256
- }
6257
6244
  render() {
6258
- if (this._content.textContent !== this.params.title) {
6259
- this._content.textContent = this.params.title;
6245
+ var _a;
6246
+ if (this._content.textContent !== this._title) {
6247
+ this._content.textContent = (_a = this._title) !== null && _a !== void 0 ? _a : '';
6260
6248
  }
6261
6249
  }
6262
6250
  }
@@ -9889,8 +9877,21 @@
9889
9877
  const CloseButton = () => (React.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
9890
9878
  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" })));
9891
9879
 
9880
+ function useTitle(api) {
9881
+ const [title, setTitle] = React.useState(api.title);
9882
+ React.useEffect(() => {
9883
+ const disposable = api.onDidTitleChange((event) => {
9884
+ setTitle(event.title);
9885
+ });
9886
+ return () => {
9887
+ disposable.dispose();
9888
+ };
9889
+ }, [api]);
9890
+ return title;
9891
+ }
9892
9892
  const DockviewDefaultTab = (_a) => {
9893
9893
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9894
+ const title = useTitle(api);
9894
9895
  const onClose = React.useCallback((event) => {
9895
9896
  event.preventDefault();
9896
9897
  if (closeActionOverride) {
@@ -9913,7 +9914,7 @@
9913
9914
  }
9914
9915
  }, [api, rest.onClick]);
9915
9916
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9916
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9917
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9917
9918
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9918
9919
  React.createElement(CloseButton, null)))));
9919
9920
  };