dockview-core 4.6.2 → 4.7.0

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.
Files changed (42) hide show
  1. package/dist/cjs/constants.d.ts +1 -0
  2. package/dist/cjs/constants.js +2 -1
  3. package/dist/cjs/dnd/droptarget.js +46 -17
  4. package/dist/cjs/dockview/dockviewComponent.d.ts +6 -0
  5. package/dist/cjs/dockview/dockviewComponent.js +112 -85
  6. package/dist/cjs/gridview/gridview.d.ts +1 -0
  7. package/dist/cjs/gridview/gridview.js +37 -0
  8. package/dist/cjs/overlay/overlayRenderContainer.d.ts +3 -0
  9. package/dist/cjs/overlay/overlayRenderContainer.js +82 -8
  10. package/dist/dockview-core.amd.js +215 -55
  11. package/dist/dockview-core.amd.js.map +1 -1
  12. package/dist/dockview-core.amd.min.js +2 -2
  13. package/dist/dockview-core.amd.min.js.map +1 -1
  14. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  15. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  16. package/dist/dockview-core.amd.noStyle.js +214 -54
  17. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  18. package/dist/dockview-core.cjs.js +215 -55
  19. package/dist/dockview-core.cjs.js.map +1 -1
  20. package/dist/dockview-core.esm.js +215 -55
  21. package/dist/dockview-core.esm.js.map +1 -1
  22. package/dist/dockview-core.esm.min.js +2 -2
  23. package/dist/dockview-core.esm.min.js.map +1 -1
  24. package/dist/dockview-core.js +215 -55
  25. package/dist/dockview-core.js.map +1 -1
  26. package/dist/dockview-core.min.js +2 -2
  27. package/dist/dockview-core.min.js.map +1 -1
  28. package/dist/dockview-core.min.noStyle.js +2 -2
  29. package/dist/dockview-core.min.noStyle.js.map +1 -1
  30. package/dist/dockview-core.noStyle.js +214 -54
  31. package/dist/dockview-core.noStyle.js.map +1 -1
  32. package/dist/esm/constants.d.ts +1 -0
  33. package/dist/esm/constants.js +1 -0
  34. package/dist/esm/dnd/droptarget.js +46 -17
  35. package/dist/esm/dockview/dockviewComponent.d.ts +6 -0
  36. package/dist/esm/dockview/dockviewComponent.js +62 -29
  37. package/dist/esm/gridview/gridview.d.ts +1 -0
  38. package/dist/esm/gridview/gridview.js +36 -0
  39. package/dist/esm/overlay/overlayRenderContainer.d.ts +3 -0
  40. package/dist/esm/overlay/overlayRenderContainer.js +69 -8
  41. package/dist/styles/dockview.css +37 -5
  42. package/package.json +1 -1
@@ -30,6 +30,36 @@ exports.OverlayRenderContainer = void 0;
30
30
  var dnd_1 = require("../dnd/dnd");
31
31
  var dom_1 = require("../dom");
32
32
  var lifecycle_1 = require("../lifecycle");
33
+ var PositionCache = /** @class */ (function () {
34
+ function PositionCache() {
35
+ this.cache = new Map();
36
+ this.currentFrameId = 0;
37
+ this.rafId = null;
38
+ }
39
+ PositionCache.prototype.getPosition = function (element) {
40
+ var cached = this.cache.get(element);
41
+ if (cached && cached.frameId === this.currentFrameId) {
42
+ return cached.rect;
43
+ }
44
+ this.scheduleFrameUpdate();
45
+ var rect = (0, dom_1.getDomNodePagePosition)(element);
46
+ this.cache.set(element, { rect: rect, frameId: this.currentFrameId });
47
+ return rect;
48
+ };
49
+ PositionCache.prototype.invalidate = function () {
50
+ this.currentFrameId++;
51
+ };
52
+ PositionCache.prototype.scheduleFrameUpdate = function () {
53
+ var _this = this;
54
+ if (this.rafId)
55
+ return;
56
+ this.rafId = requestAnimationFrame(function () {
57
+ _this.currentFrameId++;
58
+ _this.rafId = null;
59
+ });
60
+ };
61
+ return PositionCache;
62
+ }());
33
63
  function createFocusableElement() {
34
64
  var element = document.createElement('div');
35
65
  element.tabIndex = -1;
@@ -43,6 +73,8 @@ var OverlayRenderContainer = /** @class */ (function (_super) {
43
73
  _this.accessor = accessor;
44
74
  _this.map = {};
45
75
  _this._disposed = false;
76
+ _this.positionCache = new PositionCache();
77
+ _this.pendingUpdates = new Set();
46
78
  _this.addDisposables(lifecycle_1.Disposable.from(function () {
47
79
  var e_1, _a;
48
80
  try {
@@ -63,6 +95,30 @@ var OverlayRenderContainer = /** @class */ (function (_super) {
63
95
  }));
64
96
  return _this;
65
97
  }
98
+ OverlayRenderContainer.prototype.updateAllPositions = function () {
99
+ var e_2, _a;
100
+ if (this._disposed) {
101
+ return;
102
+ }
103
+ // Invalidate position cache to force recalculation
104
+ this.positionCache.invalidate();
105
+ try {
106
+ // Call resize function directly for all visible panels
107
+ for (var _b = __values(Object.values(this.map)), _c = _b.next(); !_c.done; _c = _b.next()) {
108
+ var entry = _c.value;
109
+ if (entry.panel.api.isVisible && entry.resize) {
110
+ entry.resize();
111
+ }
112
+ }
113
+ }
114
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
115
+ finally {
116
+ try {
117
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
118
+ }
119
+ finally { if (e_2) throw e_2.error; }
120
+ }
121
+ };
66
122
  OverlayRenderContainer.prototype.detatch = function (panel) {
67
123
  if (this.map[panel.api.id]) {
68
124
  var _a = this.map[panel.api.id], disposable = _a.disposable, destroy = _a.destroy;
@@ -94,17 +150,33 @@ var OverlayRenderContainer = /** @class */ (function (_super) {
94
150
  this.element.appendChild(focusContainer);
95
151
  }
96
152
  var resize = function () {
97
- // TODO propagate position to avoid getDomNodePagePosition calls, possible performance bottleneck?
98
- var box = (0, dom_1.getDomNodePagePosition)(referenceContainer.element);
99
- var box2 = (0, dom_1.getDomNodePagePosition)(_this.element);
100
- focusContainer.style.left = "".concat(box.left - box2.left, "px");
101
- focusContainer.style.top = "".concat(box.top - box2.top, "px");
102
- focusContainer.style.width = "".concat(box.width, "px");
103
- focusContainer.style.height = "".concat(box.height, "px");
104
- (0, dom_1.toggleClass)(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
153
+ var panelId = panel.api.id;
154
+ if (_this.pendingUpdates.has(panelId)) {
155
+ return; // Update already scheduled
156
+ }
157
+ _this.pendingUpdates.add(panelId);
158
+ requestAnimationFrame(function () {
159
+ _this.pendingUpdates.delete(panelId);
160
+ if (_this.isDisposed || !_this.map[panelId]) {
161
+ return;
162
+ }
163
+ var box = _this.positionCache.getPosition(referenceContainer.element);
164
+ var box2 = _this.positionCache.getPosition(_this.element);
165
+ // Use traditional positioning for overlay containers
166
+ var left = box.left - box2.left;
167
+ var top = box.top - box2.top;
168
+ var width = box.width;
169
+ var height = box.height;
170
+ focusContainer.style.left = "".concat(left, "px");
171
+ focusContainer.style.top = "".concat(top, "px");
172
+ focusContainer.style.width = "".concat(width, "px");
173
+ focusContainer.style.height = "".concat(height, "px");
174
+ (0, dom_1.toggleClass)(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
175
+ });
105
176
  };
106
177
  var visibilityChanged = function () {
107
178
  if (panel.api.isVisible) {
179
+ _this.positionCache.invalidate();
108
180
  resize();
109
181
  }
110
182
  focusContainer.style.display = panel.api.isVisible ? '' : 'none';
@@ -201,6 +273,8 @@ var OverlayRenderContainer = /** @class */ (function (_super) {
201
273
  this.map[panel.api.id].disposable.dispose();
202
274
  // and reset the disposable to the active reference-container
203
275
  this.map[panel.api.id].disposable = disposable;
276
+ // store the resize function for direct access
277
+ this.map[panel.api.id].resize = resize;
204
278
  return focusContainer;
205
279
  };
206
280
  return OverlayRenderContainer;