dockview-react 8.6.1 → 8.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.
package/dist/dockview-react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview-react
|
|
3
|
-
* @version 8.
|
|
3
|
+
* @version 8.7.0
|
|
4
4
|
* @link https://github.com/dockview/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -51,7 +51,7 @@ react_dom = __toESM(react_dom);
|
|
|
51
51
|
//#region ../dockview-core/dist/package/main.esm.mjs
|
|
52
52
|
/**
|
|
53
53
|
* dockview-core
|
|
54
|
-
* @version 8.
|
|
54
|
+
* @version 8.7.0
|
|
55
55
|
* @link https://github.com/dockview/dockview
|
|
56
56
|
* @license MIT
|
|
57
57
|
*/
|
|
@@ -725,7 +725,7 @@ react_dom = __toESM(react_dom);
|
|
|
725
725
|
resizeTimeout = setTimeout(() => {
|
|
726
726
|
cb();
|
|
727
727
|
}, DEBOUCE_DELAY);
|
|
728
|
-
}));
|
|
728
|
+
}), Disposable.from(() => clearTimeout(resizeTimeout)));
|
|
729
729
|
}
|
|
730
730
|
function shiftAbsoluteElementIntoView(element, root, options) {
|
|
731
731
|
var _options$buffer;
|
|
@@ -3953,6 +3953,33 @@ react_dom = __toESM(react_dom);
|
|
|
3953
3953
|
return this.component.withOrigin("api", () => this.component.addGroup(options));
|
|
3954
3954
|
}
|
|
3955
3955
|
/**
|
|
3956
|
+
* Serialize one group together with the state of every panel it holds.
|
|
3957
|
+
* The result is self-contained and can be rehydrated with
|
|
3958
|
+
* `addGroupFromJSON`, on this instance or another one.
|
|
3959
|
+
*/
|
|
3960
|
+
serializeGroup(group) {
|
|
3961
|
+
return this.component.serializeGroup(group);
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Rebuild a group from `serializeGroup` output and add it to the live
|
|
3965
|
+
* layout, positioned as for `addGroup`, leaving the rest of the layout
|
|
3966
|
+
* untouched. Throws before changing anything if a panel id is already in
|
|
3967
|
+
* use.
|
|
3968
|
+
*/
|
|
3969
|
+
addGroupFromJSON(data, options) {
|
|
3970
|
+
return this.component.withOrigin("api", () => this.component.addGroupFromJSON(data, options));
|
|
3971
|
+
}
|
|
3972
|
+
/**
|
|
3973
|
+
* Add a panel from its `toJSON()` state, placed as `addPanel` places
|
|
3974
|
+
* one: the counterpart to `panel.toJSON()` for a single tab moving
|
|
3975
|
+
* between layouts or instances, as `addGroupFromJSON` is to
|
|
3976
|
+
* `serializeGroup`. Throws before changing anything if the panel id is
|
|
3977
|
+
* already in use.
|
|
3978
|
+
*/
|
|
3979
|
+
addPanelFromJSON(state, options) {
|
|
3980
|
+
return this.component.withOrigin("api", () => this.component.addPanelFromJSON(state, options));
|
|
3981
|
+
}
|
|
3982
|
+
/**
|
|
3956
3983
|
* Close all groups and panels.
|
|
3957
3984
|
*/
|
|
3958
3985
|
closeAllGroups() {
|
|
@@ -6933,9 +6960,11 @@ react_dom = __toESM(react_dom);
|
|
|
6933
6960
|
className: void 0,
|
|
6934
6961
|
noPanelsOverlay: void 0,
|
|
6935
6962
|
closeEmptyGroups: void 0,
|
|
6963
|
+
groupIdGenerator: void 0,
|
|
6936
6964
|
dndEdges: void 0,
|
|
6937
6965
|
dropPositionResolver: void 0,
|
|
6938
6966
|
dndCompass: void 0,
|
|
6967
|
+
dropSizing: void 0,
|
|
6939
6968
|
theme: void 0,
|
|
6940
6969
|
disableTabsOverflowList: void 0,
|
|
6941
6970
|
overflow: void 0,
|
|
@@ -10461,6 +10490,15 @@ react_dom = __toESM(react_dom);
|
|
|
10461
10490
|
get panel() {
|
|
10462
10491
|
return this.options.panel;
|
|
10463
10492
|
}
|
|
10493
|
+
/**
|
|
10494
|
+
* For a drop on a group's tab bar, the tab index the drop landed at:
|
|
10495
|
+
* where a panel added in response belongs (`addPanel`'s `index`, or
|
|
10496
|
+
* `addGroupFromJSON` with `direction: 'within'`). `undefined` for a
|
|
10497
|
+
* drop on a group's content or a layout edge.
|
|
10498
|
+
*/
|
|
10499
|
+
get index() {
|
|
10500
|
+
return this.options.index;
|
|
10501
|
+
}
|
|
10464
10502
|
get group() {
|
|
10465
10503
|
return this.options.group;
|
|
10466
10504
|
}
|
|
@@ -11396,6 +11434,7 @@ react_dom = __toESM(react_dom);
|
|
|
11396
11434
|
nativeEvent: event,
|
|
11397
11435
|
position,
|
|
11398
11436
|
panel,
|
|
11437
|
+
index,
|
|
11399
11438
|
getData: () => getPanelData(),
|
|
11400
11439
|
kind: getKind(),
|
|
11401
11440
|
group: this.groupPanel,
|
|
@@ -11441,6 +11480,7 @@ react_dom = __toESM(react_dom);
|
|
|
11441
11480
|
nativeEvent: event,
|
|
11442
11481
|
position,
|
|
11443
11482
|
panel,
|
|
11483
|
+
index,
|
|
11444
11484
|
getData: () => getPanelData(),
|
|
11445
11485
|
group: this.groupPanel,
|
|
11446
11486
|
api: this._api
|
|
@@ -15656,6 +15696,8 @@ react_dom = __toESM(react_dom);
|
|
|
15656
15696
|
/** A never-firing history-change event, the fallback `onDidChangeHistory`
|
|
15657
15697
|
* returns when the LayoutHistory module is absent. */
|
|
15658
15698
|
const NO_LAYOUT_HISTORY_CHANGES = NO_EVENT;
|
|
15699
|
+
/** How many live ids a custom `groupIdGenerator` may return before giving up. */
|
|
15700
|
+
const MAX_GROUP_ID_ATTEMPTS = 100;
|
|
15659
15701
|
var DockviewComponent = class extends BaseGrid {
|
|
15660
15702
|
fireDidCreateTabGroup(event) {
|
|
15661
15703
|
this._onDidCreateTabGroup.fire(event);
|
|
@@ -17505,7 +17547,7 @@ react_dom = __toESM(react_dom);
|
|
|
17505
17547
|
if (typeof id !== "string") throw new TypeError("dockview: group id must be of type string");
|
|
17506
17548
|
const group = this.createGroup({
|
|
17507
17549
|
id,
|
|
17508
|
-
locked:
|
|
17550
|
+
locked: locked !== null && locked !== void 0 ? locked : false,
|
|
17509
17551
|
hideHeader: !!hideHeader,
|
|
17510
17552
|
headerPosition
|
|
17511
17553
|
});
|
|
@@ -17778,6 +17820,32 @@ react_dom = __toESM(react_dom);
|
|
|
17778
17820
|
addPanel(options) {
|
|
17779
17821
|
return this.mutation("add", () => this._doAddPanel(options));
|
|
17780
17822
|
}
|
|
17823
|
+
/**
|
|
17824
|
+
* Add a panel from its `toJSON()` state, placed as `addPanel` places
|
|
17825
|
+
* one: the counterpart to `panel.toJSON()` for a single tab moving
|
|
17826
|
+
* between layouts or instances, as `addGroupFromJSON` is to
|
|
17827
|
+
* `serializeGroup`. Throws before changing anything if the panel id is
|
|
17828
|
+
* already in use.
|
|
17829
|
+
*/
|
|
17830
|
+
addPanelFromJSON(state, options) {
|
|
17831
|
+
if (!state.contentComponent) throw new Error(`dockview: serialized panel ${state.id} has no contentComponent`);
|
|
17832
|
+
return this.mutation("add", () => {
|
|
17833
|
+
const panel = this._doAddPanel(_objectSpread2$1(_objectSpread2$1({}, options), {}, {
|
|
17834
|
+
id: state.id,
|
|
17835
|
+
component: state.contentComponent,
|
|
17836
|
+
tabComponent: state.tabComponent,
|
|
17837
|
+
title: state.title,
|
|
17838
|
+
renderer: state.renderer,
|
|
17839
|
+
params: state.params,
|
|
17840
|
+
minimumWidth: state.minimumWidth,
|
|
17841
|
+
minimumHeight: state.minimumHeight,
|
|
17842
|
+
maximumWidth: state.maximumWidth,
|
|
17843
|
+
maximumHeight: state.maximumHeight
|
|
17844
|
+
}));
|
|
17845
|
+
if (state.pinned) this.setPanelPinned(panel, true);
|
|
17846
|
+
return panel;
|
|
17847
|
+
});
|
|
17848
|
+
}
|
|
17781
17849
|
_doAddPanel(options) {
|
|
17782
17850
|
if (this.panels.some((_) => _.id === options.id)) throw new Error(`dockview: panel with id ${options.id} already exists`);
|
|
17783
17851
|
let referenceGroup;
|
|
@@ -17919,6 +17987,152 @@ react_dom = __toESM(react_dom);
|
|
|
17919
17987
|
addGroup(options) {
|
|
17920
17988
|
return this.mutation("add", () => this._doAddGroup(options));
|
|
17921
17989
|
}
|
|
17990
|
+
/**
|
|
17991
|
+
* Serialize one group and the state of every panel it holds. The result
|
|
17992
|
+
* is self-contained: `addGroupFromJSON` on any dockview instance rebuilds
|
|
17993
|
+
* the group from it, with the same tab order, active tab, panel titles,
|
|
17994
|
+
* parameters and renderers.
|
|
17995
|
+
*/
|
|
17996
|
+
serializeGroup(group) {
|
|
17997
|
+
const panels = {};
|
|
17998
|
+
for (const panel of group.panels) panels[panel.id] = panel.toJSON();
|
|
17999
|
+
return {
|
|
18000
|
+
group: group.model.toJSON(),
|
|
18001
|
+
panels
|
|
18002
|
+
};
|
|
18003
|
+
}
|
|
18004
|
+
/**
|
|
18005
|
+
* Rebuild a group from `serializeGroup` output and add it to the live
|
|
18006
|
+
* layout at `options` (as for `addGroup`), without touching the rest of
|
|
18007
|
+
* the layout. This is the counterpart to `fromJSON`, which replaces the
|
|
18008
|
+
* whole layout, for moving one group between layouts or instances.
|
|
18009
|
+
*
|
|
18010
|
+
* With `direction: 'within'` and a reference group or panel, no group is
|
|
18011
|
+
* created: the serialized panels are merged into that group, in their
|
|
18012
|
+
* order, at `index` if given, and the serialized active panel becomes
|
|
18013
|
+
* the group's. The serialized group's own shape (id, locked, header,
|
|
18014
|
+
* tab groups) does not apply then. This is what a drop on a group's
|
|
18015
|
+
* centre or tab bar calls for, and the only form that works against a
|
|
18016
|
+
* floating or edge group, which has no grid neighbours.
|
|
18017
|
+
*
|
|
18018
|
+
* A panel id that is already live throws, as `addPanel` does, before
|
|
18019
|
+
* anything is changed. A group id that is already live is reassigned with
|
|
18020
|
+
* a warning, as `addGroup` does.
|
|
18021
|
+
*/
|
|
18022
|
+
addGroupFromJSON(data, options) {
|
|
18023
|
+
this.validateSerializedGroup(data);
|
|
18024
|
+
return this.mutation("add", () => this._doAddGroupFromJSON(data, options));
|
|
18025
|
+
}
|
|
18026
|
+
/**
|
|
18027
|
+
* Refuse an envelope that cannot be applied cleanly, before any mutation
|
|
18028
|
+
* is opened, so a refused call leaves no trace in the layout or its
|
|
18029
|
+
* events.
|
|
18030
|
+
*/
|
|
18031
|
+
validateSerializedGroup(data) {
|
|
18032
|
+
const state = data === null || data === void 0 ? void 0 : data.group;
|
|
18033
|
+
if (typeof (state === null || state === void 0 ? void 0 : state.id) !== "string") throw new TypeError("dockview: group id must be of type string");
|
|
18034
|
+
if (!Array.isArray(state.views)) throw new TypeError(`dockview: serialized group ${state.id} has no views`);
|
|
18035
|
+
for (const id of state.views) {
|
|
18036
|
+
var _data$panels;
|
|
18037
|
+
if (!((_data$panels = data.panels) === null || _data$panels === void 0 ? void 0 : _data$panels[id])) throw new Error(`dockview: serialized group ${state.id} is missing panel state for ${id}`);
|
|
18038
|
+
if (this.panels.some((panel) => panel.id === id)) throw new Error(`dockview: panel with id ${id} already exists`);
|
|
18039
|
+
}
|
|
18040
|
+
}
|
|
18041
|
+
_doAddGroupFromJSON(data, options) {
|
|
18042
|
+
var _options$direction;
|
|
18043
|
+
const { id, locked, hideHeader, headerPosition, constraints, activeView, tabGroups } = data.group;
|
|
18044
|
+
if (options && ((_options$direction = options.direction) !== null && _options$direction !== void 0 ? _options$direction : "within") === "within") {
|
|
18045
|
+
const target = this.resolveReferenceGroup(options);
|
|
18046
|
+
if (target) return this.mergeGroupFromJSON(data, target, options);
|
|
18047
|
+
}
|
|
18048
|
+
const groupOptions = {
|
|
18049
|
+
id,
|
|
18050
|
+
locked: locked !== null && locked !== void 0 ? locked : false,
|
|
18051
|
+
hideHeader: !!hideHeader,
|
|
18052
|
+
headerPosition,
|
|
18053
|
+
constraints,
|
|
18054
|
+
initialWidth: options === null || options === void 0 ? void 0 : options.initialWidth,
|
|
18055
|
+
initialHeight: options === null || options === void 0 ? void 0 : options.initialHeight,
|
|
18056
|
+
skipSetActive: true
|
|
18057
|
+
};
|
|
18058
|
+
const group = this.addEmptyGroupAt(groupOptions, options);
|
|
18059
|
+
let panels;
|
|
18060
|
+
try {
|
|
18061
|
+
panels = this.deserializePanels(data, group);
|
|
18062
|
+
} catch (err) {
|
|
18063
|
+
this.doRemoveGroup(group, { skipActive: true });
|
|
18064
|
+
throw err;
|
|
18065
|
+
}
|
|
18066
|
+
for (const panel of panels) group.model.openPanel(panel, {
|
|
18067
|
+
skipSetActive: panel.id !== activeView,
|
|
18068
|
+
skipSetGroupActive: true
|
|
18069
|
+
});
|
|
18070
|
+
if (tabGroups && tabGroups.length > 0) group.model.restoreTabGroups(tabGroups);
|
|
18071
|
+
if (!group.activePanel && group.panels.length > 0) group.model.openPanel(group.panels[group.panels.length - 1], { skipSetGroupActive: true });
|
|
18072
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipSetActive)) this.doSetGroupAndPanelActive(group);
|
|
18073
|
+
return group;
|
|
18074
|
+
}
|
|
18075
|
+
/**
|
|
18076
|
+
* Add an empty group at the placement `options` names, or append it
|
|
18077
|
+
* when they name none.
|
|
18078
|
+
*/
|
|
18079
|
+
addEmptyGroupAt(groupOptions, options) {
|
|
18080
|
+
if (options !== void 0 && (isGroupOptionsWithPanel(options) || isGroupOptionsWithGroup(options) || typeof options.direction === "string")) return this._doAddGroup(_objectSpread2$1(_objectSpread2$1({}, options), groupOptions));
|
|
18081
|
+
const group = this.createGroup(groupOptions);
|
|
18082
|
+
this.doAddGroup(group);
|
|
18083
|
+
return group;
|
|
18084
|
+
}
|
|
18085
|
+
/**
|
|
18086
|
+
* Create every panel of a serialized group in `group`, in tab order,
|
|
18087
|
+
* before any is opened, so a corrupt panel state fails before a single
|
|
18088
|
+
* add event has fired (the ordering `fromJSON` uses). On failure the
|
|
18089
|
+
* panels made so far are disposed and the error rethrown.
|
|
18090
|
+
*/
|
|
18091
|
+
deserializePanels(data, group) {
|
|
18092
|
+
const panels = [];
|
|
18093
|
+
try {
|
|
18094
|
+
for (const child of data.group.views) panels.push(this._deserializer.fromJSON(data.panels[child], group));
|
|
18095
|
+
} catch (err) {
|
|
18096
|
+
for (const panel of panels) panel.dispose();
|
|
18097
|
+
throw err;
|
|
18098
|
+
}
|
|
18099
|
+
return panels;
|
|
18100
|
+
}
|
|
18101
|
+
/**
|
|
18102
|
+
* The group an `AddGroupOptions` placement names, or `undefined` for an
|
|
18103
|
+
* absolute placement. Throws for a reference that names nothing.
|
|
18104
|
+
*/
|
|
18105
|
+
resolveReferenceGroup(options) {
|
|
18106
|
+
if (isGroupOptionsWithPanel(options)) {
|
|
18107
|
+
const referencePanelId = typeof options.referencePanel === "string" ? options.referencePanel : options.referencePanel.id;
|
|
18108
|
+
const referencePanel = this.getGroupPanel(referencePanelId);
|
|
18109
|
+
if (!referencePanel) throw new Error(`dockview: reference panel ${referencePanelId} does not exist`);
|
|
18110
|
+
return referencePanel.group;
|
|
18111
|
+
}
|
|
18112
|
+
if (isGroupOptionsWithGroup(options)) {
|
|
18113
|
+
const referenceId = typeof options.referenceGroup === "string" ? options.referenceGroup : options.referenceGroup.id;
|
|
18114
|
+
const referenceGroup = this.getPanel(referenceId);
|
|
18115
|
+
if (!referenceGroup) throw new Error(`dockview: reference group ${referenceId} does not exist`);
|
|
18116
|
+
return referenceGroup;
|
|
18117
|
+
}
|
|
18118
|
+
}
|
|
18119
|
+
/**
|
|
18120
|
+
* The `direction: 'within'` form of `addGroupFromJSON`: the serialized
|
|
18121
|
+
* panels join `target` rather than a group of their own.
|
|
18122
|
+
*/
|
|
18123
|
+
mergeGroupFromJSON(data, target, options) {
|
|
18124
|
+
const { activeView } = data.group;
|
|
18125
|
+
const index = options.index;
|
|
18126
|
+
this.deserializePanels(data, target).forEach((panel, offset) => {
|
|
18127
|
+
target.model.openPanel(panel, {
|
|
18128
|
+
index: index === void 0 ? void 0 : index + offset,
|
|
18129
|
+
skipSetActive: panel.id !== activeView,
|
|
18130
|
+
skipSetGroupActive: true
|
|
18131
|
+
});
|
|
18132
|
+
});
|
|
18133
|
+
if (!options.skipSetActive) this.doSetGroupAndPanelActive(target);
|
|
18134
|
+
return target;
|
|
18135
|
+
}
|
|
17922
18136
|
_doAddGroup(options) {
|
|
17923
18137
|
if (options) {
|
|
17924
18138
|
let referenceGroup;
|
|
@@ -18342,7 +18556,7 @@ react_dom = __toESM(react_dom);
|
|
|
18342
18556
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
18343
18557
|
if (sourceGroup.api.location.type === "grid" && destinationGridview === this.gridview) {
|
|
18344
18558
|
const [sourceParentLocation, from] = tail(getGridLocation(sourceGroup.element));
|
|
18345
|
-
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
18559
|
+
if ((this.options.dropSizing !== "distribute" || sourceGroup === destinationGroup) && sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
18346
18560
|
this.gridview.moveView(sourceParentLocation, from, to);
|
|
18347
18561
|
this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
|
|
18348
18562
|
return;
|
|
@@ -18372,7 +18586,7 @@ react_dom = __toESM(react_dom);
|
|
|
18372
18586
|
}));
|
|
18373
18587
|
this.doRemoveGroup(sourceGroup, { skipActive: true });
|
|
18374
18588
|
const updatedTargetLocation = getRelativeLocation(destinationGridview.orientation, getGridLocation(destinationGroup.element), destinationTarget);
|
|
18375
|
-
const newGroup = this.createGroupAtLocation(updatedTargetLocation, this.
|
|
18589
|
+
const newGroup = this.createGroupAtLocation(updatedTargetLocation, this.sizingForDrop(getGridLocation(destinationGroup.element)), void 0, destinationGridview);
|
|
18376
18590
|
this.movingLock(() => newGroup.model.openPanel(removedPanel, { skipSetActive: true }));
|
|
18377
18591
|
this.doSetGroupAndPanelActive(newGroup);
|
|
18378
18592
|
this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
|
|
@@ -18389,7 +18603,7 @@ react_dom = __toESM(react_dom);
|
|
|
18389
18603
|
skipSetActiveGroup: true
|
|
18390
18604
|
}));
|
|
18391
18605
|
if (!removedPanel) throw new Error(`dockview: No panel with id ${sourceItemId}`);
|
|
18392
|
-
const newGroup = this.createGroupAtLocation(targetLocation, this.
|
|
18606
|
+
const newGroup = this.createGroupAtLocation(targetLocation, this.sizingForDrop(referenceLocation), void 0, destinationGridview);
|
|
18393
18607
|
this.movingLock(() => newGroup.model.openPanel(removedPanel, { skipSetGroupActive: true }));
|
|
18394
18608
|
this.doSetGroupAndPanelActive(newGroup);
|
|
18395
18609
|
this.fireDidMovePanel(removedPanel, sourceGroup);
|
|
@@ -18401,7 +18615,7 @@ react_dom = __toESM(react_dom);
|
|
|
18401
18615
|
}));
|
|
18402
18616
|
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
18403
18617
|
const location = getRelativeLocation(destinationGridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
18404
|
-
this.movingLock(() => this.doAddGroup(targetGroup, location, this.
|
|
18618
|
+
this.movingLock(() => this.doAddGroup(targetGroup, location, this.sizingForDrop(updatedReferenceLocation), destinationGridview));
|
|
18405
18619
|
this.setGroupLocationForRoot(targetGroup, destinationGridview);
|
|
18406
18620
|
this.doSetGroupAndPanelActive(targetGroup);
|
|
18407
18621
|
this.fireDidMovePanel(this.getGroupPanel(sourceItemId), sourceGroup);
|
|
@@ -18416,7 +18630,7 @@ react_dom = __toESM(react_dom);
|
|
|
18416
18630
|
}));
|
|
18417
18631
|
if (!removedPanel) throw new Error(`dockview: No panel with id ${sourceItemId}`);
|
|
18418
18632
|
const dropLocation = getRelativeLocation(destinationGridview.orientation, referenceLocation, destinationTarget);
|
|
18419
|
-
const group = this.createGroupAtLocation(dropLocation, this.
|
|
18633
|
+
const group = this.createGroupAtLocation(dropLocation, this.sizingForDrop(referenceLocation), void 0, destinationGridview);
|
|
18420
18634
|
this.movingLock(() => group.model.openPanel(removedPanel, { skipSetGroupActive: true }));
|
|
18421
18635
|
this.doSetGroupAndPanelActive(group);
|
|
18422
18636
|
this.fireDidMovePanel(removedPanel, sourceGroup);
|
|
@@ -18460,7 +18674,7 @@ react_dom = __toESM(react_dom);
|
|
|
18460
18674
|
if (!destinationTarget || destinationTarget === "center" || !referenceLocation) targetGroup = destinationGroup;
|
|
18461
18675
|
else {
|
|
18462
18676
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
18463
|
-
targetGroup = this.createGroupAtLocation(dropLocation, this.
|
|
18677
|
+
targetGroup = this.createGroupAtLocation(dropLocation, this.sizingForDrop(referenceLocation));
|
|
18464
18678
|
}
|
|
18465
18679
|
if (!this.keepEmptyGroups(options) && sourceGroup.model.size === 0 && sourceGroup !== targetGroup) this.doRemoveGroup(sourceGroup, { skipActive: true });
|
|
18466
18680
|
addPanelsToGroup(targetGroup);
|
|
@@ -18592,11 +18806,8 @@ react_dom = __toESM(react_dom);
|
|
|
18592
18806
|
const referenceLocation = getGridLocation(to.element);
|
|
18593
18807
|
const dropLocation = getRelativeLocation(destGridview.orientation, referenceLocation, target);
|
|
18594
18808
|
let size;
|
|
18595
|
-
if (isReorderWithinBranch) size = getDirectionOrientation(target) === "HORIZONTAL" ? from.api.width : from.api.height;
|
|
18596
|
-
else
|
|
18597
|
-
var _referenceLocation;
|
|
18598
|
-
size = Sizing.Split((_referenceLocation = referenceLocation[referenceLocation.length - 1]) !== null && _referenceLocation !== void 0 ? _referenceLocation : 0);
|
|
18599
|
-
}
|
|
18809
|
+
if (isReorderWithinBranch && this.options.dropSizing !== "distribute") size = getDirectionOrientation(target) === "HORIZONTAL" ? from.api.width : from.api.height;
|
|
18810
|
+
else size = this.sizingForDrop(referenceLocation);
|
|
18600
18811
|
destGridview.addView(source, size, dropLocation);
|
|
18601
18812
|
this.setGroupLocationForRoot(source, destGridview);
|
|
18602
18813
|
}
|
|
@@ -18623,10 +18834,26 @@ react_dom = __toESM(react_dom);
|
|
|
18623
18834
|
if (group && this.hasMaximizedGroup() && !this.isMaximizedGroup(group)) this.exitMaximizedGroup();
|
|
18624
18835
|
if (!this._moving && activePanel !== ((_this$_onDidActivePan2 = this._onDidActivePanelChange.value) === null || _this$_onDidActivePan2 === void 0 ? void 0 : _this$_onDidActivePan2.panel)) this.fireActivePanelChange(activePanel);
|
|
18625
18836
|
}
|
|
18837
|
+
/**
|
|
18838
|
+
* The id for a group created without one: from `groupIdGenerator` when
|
|
18839
|
+
* the option is set, else the sequential counter. An id already in use is
|
|
18840
|
+
* skipped. The counter never repeats, so it can skip any number of live
|
|
18841
|
+
* ids (a restored layout may hold many); a custom generator is given a
|
|
18842
|
+
* bounded number of tries so a broken one cannot hang the call.
|
|
18843
|
+
*/
|
|
18626
18844
|
getNextGroupId() {
|
|
18627
|
-
|
|
18628
|
-
|
|
18629
|
-
|
|
18845
|
+
const generate = this.options.groupIdGenerator;
|
|
18846
|
+
if (!generate) {
|
|
18847
|
+
let id = this.nextGroupId.next();
|
|
18848
|
+
while (this._groups.has(id)) id = this.nextGroupId.next();
|
|
18849
|
+
return id;
|
|
18850
|
+
}
|
|
18851
|
+
for (let attempt = 0; attempt < MAX_GROUP_ID_ATTEMPTS; attempt++) {
|
|
18852
|
+
const id = generate();
|
|
18853
|
+
if (typeof id !== "string" || id.length === 0) throw new TypeError("dockview: groupIdGenerator must return a non-empty string");
|
|
18854
|
+
if (!this._groups.has(id)) return id;
|
|
18855
|
+
}
|
|
18856
|
+
throw new Error(`dockview: groupIdGenerator returned an id already in use ${MAX_GROUP_ID_ATTEMPTS} times in a row`);
|
|
18630
18857
|
}
|
|
18631
18858
|
createGroup(options) {
|
|
18632
18859
|
var _options;
|
|
@@ -18636,10 +18863,7 @@ react_dom = __toESM(react_dom);
|
|
|
18636
18863
|
console.warn(`dockview: Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
|
|
18637
18864
|
id = void 0;
|
|
18638
18865
|
}
|
|
18639
|
-
if (!id)
|
|
18640
|
-
id = this.nextGroupId.next();
|
|
18641
|
-
while (this._groups.has(id)) id = this.nextGroupId.next();
|
|
18642
|
-
}
|
|
18866
|
+
if (!id) id = this.getNextGroupId();
|
|
18643
18867
|
const view = new DockviewGroupPanel(this, id, options);
|
|
18644
18868
|
view.init({
|
|
18645
18869
|
params: {},
|
|
@@ -18721,13 +18945,12 @@ react_dom = __toESM(react_dom);
|
|
|
18721
18945
|
return panel;
|
|
18722
18946
|
}
|
|
18723
18947
|
/**
|
|
18724
|
-
* Sizing for a group created by a drop next to `referenceLocation
|
|
18725
|
-
*
|
|
18726
|
-
*
|
|
18727
|
-
* rewrites the index to 0 when a cross-axis drop wraps the reference in a
|
|
18728
|
-
* new branch, so one value serves both paths.
|
|
18948
|
+
* Sizing for a group created by a drop next to `referenceLocation`.
|
|
18949
|
+
* Gridview rewrites the index to 0 when a cross-axis drop wraps the
|
|
18950
|
+
* reference in a new branch, so one split index serves both paths.
|
|
18729
18951
|
*/
|
|
18730
|
-
|
|
18952
|
+
sizingForDrop(referenceLocation) {
|
|
18953
|
+
if (this.options.dropSizing === "distribute") return Sizing.Distribute;
|
|
18731
18954
|
return Sizing.Split(referenceLocation.length === 0 ? 0 : referenceLocation[referenceLocation.length - 1]);
|
|
18732
18955
|
}
|
|
18733
18956
|
createGroupAtLocation(location, size, options, gridview = this.gridview) {
|