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
  */
@@ -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
  }
@@ -9855,8 +9843,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9855
9843
  const CloseButton = () => (React.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
9856
9844
  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" })));
9857
9845
 
9846
+ function useTitle(api) {
9847
+ const [title, setTitle] = React.useState(api.title);
9848
+ React.useEffect(() => {
9849
+ const disposable = api.onDidTitleChange((event) => {
9850
+ setTitle(event.title);
9851
+ });
9852
+ return () => {
9853
+ disposable.dispose();
9854
+ };
9855
+ }, [api]);
9856
+ return title;
9857
+ }
9858
9858
  const DockviewDefaultTab = (_a) => {
9859
9859
  var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride"]);
9860
+ const title = useTitle(api);
9860
9861
  const onClose = React.useCallback((event) => {
9861
9862
  event.preventDefault();
9862
9863
  if (closeActionOverride) {
@@ -9879,7 +9880,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9879
9880
  }
9880
9881
  }, [api, rest.onClick]);
9881
9882
  return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onClick: onClick, className: "dv-default-tab" }),
9882
- React.createElement("span", { className: "dv-default-tab-content" }, api.title),
9883
+ React.createElement("span", { className: "dv-default-tab-content" }, title),
9883
9884
  !hideClose && (React.createElement("div", { className: "dv-default-tab-action", onMouseDown: onMouseDown, onClick: onClose },
9884
9885
  React.createElement(CloseButton, null)))));
9885
9886
  };