dockview 1.9.0 → 1.9.1
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/cjs/dockview/dockview.d.ts +2 -1
- package/dist/cjs/dockview/dockview.d.ts.map +1 -1
- package/dist/cjs/dockview/dockview.js +9 -0
- package/dist/cjs/dockview/dockview.js.map +1 -1
- package/dist/dockview.amd.js +80 -60
- package/dist/dockview.amd.js.map +1 -1
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.js.map +1 -1
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.min.noStyle.js.map +1 -1
- package/dist/dockview.amd.noStyle.js +80 -60
- package/dist/dockview.amd.noStyle.js.map +1 -1
- package/dist/dockview.cjs.js +80 -60
- package/dist/dockview.cjs.js.map +1 -1
- package/dist/dockview.esm.js +80 -60
- package/dist/dockview.esm.js.map +1 -1
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.esm.min.js.map +1 -1
- package/dist/dockview.js +80 -60
- package/dist/dockview.js.map +1 -1
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.js.map +1 -1
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.min.noStyle.js.map +1 -1
- package/dist/dockview.noStyle.js +80 -60
- package/dist/dockview.noStyle.js.map +1 -1
- package/dist/esm/dockview/dockview.d.ts +2 -1
- package/dist/esm/dockview/dockview.d.ts.map +1 -1
- package/dist/esm/dockview/dockview.js +9 -0
- package/dist/esm/dockview/dockview.js.map +1 -1
- package/package.json +2 -2
package/dist/dockview.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.9.
|
|
3
|
+
* @version 1.9.1
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -3109,9 +3109,6 @@ class DragAndDropObserver extends CompositeDisposable {
|
|
|
3109
3109
|
}
|
|
3110
3110
|
}
|
|
3111
3111
|
|
|
3112
|
-
function numberOrFallback(maybeNumber, fallback) {
|
|
3113
|
-
return typeof maybeNumber === 'number' ? maybeNumber : fallback;
|
|
3114
|
-
}
|
|
3115
3112
|
function directionToPosition(direction) {
|
|
3116
3113
|
switch (direction) {
|
|
3117
3114
|
case 'above':
|
|
@@ -3144,6 +3141,16 @@ function positionToDirection(position) {
|
|
|
3144
3141
|
throw new Error(`invalid position '${position}'`);
|
|
3145
3142
|
}
|
|
3146
3143
|
}
|
|
3144
|
+
const DEFAULT_ACTIVATION_SIZE = {
|
|
3145
|
+
value: 20,
|
|
3146
|
+
type: 'percentage',
|
|
3147
|
+
};
|
|
3148
|
+
const DEFAULT_SIZE = {
|
|
3149
|
+
value: 50,
|
|
3150
|
+
type: 'percentage',
|
|
3151
|
+
};
|
|
3152
|
+
const SMALL_WIDTH_BOUNDARY = 100;
|
|
3153
|
+
const SMALL_HEIGHT_BOUNDARY = 100;
|
|
3147
3154
|
class Droptarget extends CompositeDisposable {
|
|
3148
3155
|
get state() {
|
|
3149
3156
|
return this._state;
|
|
@@ -3204,7 +3211,7 @@ class Droptarget extends CompositeDisposable {
|
|
|
3204
3211
|
this.element.append(this.targetElement);
|
|
3205
3212
|
}
|
|
3206
3213
|
this.toggleClasses(quadrant, width, height);
|
|
3207
|
-
this.
|
|
3214
|
+
this._state = quadrant;
|
|
3208
3215
|
},
|
|
3209
3216
|
onDragLeave: () => {
|
|
3210
3217
|
this.removeDropTarget();
|
|
@@ -3229,6 +3236,9 @@ class Droptarget extends CompositeDisposable {
|
|
|
3229
3236
|
setTargetZones(acceptedTargetZones) {
|
|
3230
3237
|
this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
|
|
3231
3238
|
}
|
|
3239
|
+
setOverlayModel(model) {
|
|
3240
|
+
this.options.overlayModel = model;
|
|
3241
|
+
}
|
|
3232
3242
|
dispose() {
|
|
3233
3243
|
this.removeDropTarget();
|
|
3234
3244
|
super.dispose();
|
|
@@ -3240,19 +3250,19 @@ class Droptarget extends CompositeDisposable {
|
|
|
3240
3250
|
event[Droptarget.USED_EVENT_ID] = true;
|
|
3241
3251
|
}
|
|
3242
3252
|
/**
|
|
3243
|
-
* Check is the event has already been used by another instance
|
|
3253
|
+
* Check is the event has already been used by another instance of DropTarget
|
|
3244
3254
|
*/
|
|
3245
3255
|
isAlreadyUsed(event) {
|
|
3246
3256
|
const value = event[Droptarget.USED_EVENT_ID];
|
|
3247
3257
|
return typeof value === 'boolean' && value;
|
|
3248
3258
|
}
|
|
3249
3259
|
toggleClasses(quadrant, width, height) {
|
|
3250
|
-
var _a, _b
|
|
3260
|
+
var _a, _b;
|
|
3251
3261
|
if (!this.overlayElement) {
|
|
3252
3262
|
return;
|
|
3253
3263
|
}
|
|
3254
|
-
const isSmallX = width <
|
|
3255
|
-
const isSmallY = height <
|
|
3264
|
+
const isSmallX = width < SMALL_WIDTH_BOUNDARY;
|
|
3265
|
+
const isSmallY = height < SMALL_HEIGHT_BOUNDARY;
|
|
3256
3266
|
const isLeft = quadrant === 'left';
|
|
3257
3267
|
const isRight = quadrant === 'right';
|
|
3258
3268
|
const isTop = quadrant === 'top';
|
|
@@ -3261,20 +3271,17 @@ class Droptarget extends CompositeDisposable {
|
|
|
3261
3271
|
const leftClass = !isSmallX && isLeft;
|
|
3262
3272
|
const topClass = !isSmallY && isTop;
|
|
3263
3273
|
const bottomClass = !isSmallY && isBottom;
|
|
3264
|
-
let size =
|
|
3265
|
-
|
|
3266
|
-
|
|
3274
|
+
let size = 1;
|
|
3275
|
+
const sizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : DEFAULT_SIZE;
|
|
3276
|
+
if (sizeOptions.type === 'percentage') {
|
|
3277
|
+
size = clamp(sizeOptions.value, 0, 100) / 100;
|
|
3267
3278
|
}
|
|
3268
|
-
|
|
3279
|
+
else {
|
|
3269
3280
|
if (rightClass || leftClass) {
|
|
3270
|
-
size =
|
|
3271
|
-
clamp(0, this.options.overlayModel.size.value, width) /
|
|
3272
|
-
width;
|
|
3281
|
+
size = clamp(0, sizeOptions.value, width) / width;
|
|
3273
3282
|
}
|
|
3274
3283
|
if (topClass || bottomClass) {
|
|
3275
|
-
size =
|
|
3276
|
-
clamp(0, this.options.overlayModel.size.value, height) /
|
|
3277
|
-
height;
|
|
3284
|
+
size = clamp(0, sizeOptions.value, height) / height;
|
|
3278
3285
|
}
|
|
3279
3286
|
}
|
|
3280
3287
|
const translate = (1 - size) / 2;
|
|
@@ -3296,39 +3303,22 @@ class Droptarget extends CompositeDisposable {
|
|
|
3296
3303
|
transform = '';
|
|
3297
3304
|
}
|
|
3298
3305
|
this.overlayElement.style.transform = transform;
|
|
3299
|
-
toggleClass(this.overlayElement, 'small-
|
|
3300
|
-
toggleClass(this.overlayElement, 'small-
|
|
3301
|
-
toggleClass(this.overlayElement, '
|
|
3302
|
-
toggleClass(this.overlayElement, '
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
case 'top':
|
|
3307
|
-
this._state = 'top';
|
|
3308
|
-
break;
|
|
3309
|
-
case 'left':
|
|
3310
|
-
this._state = 'left';
|
|
3311
|
-
break;
|
|
3312
|
-
case 'bottom':
|
|
3313
|
-
this._state = 'bottom';
|
|
3314
|
-
break;
|
|
3315
|
-
case 'right':
|
|
3316
|
-
this._state = 'right';
|
|
3317
|
-
break;
|
|
3318
|
-
case 'center':
|
|
3319
|
-
this._state = 'center';
|
|
3320
|
-
break;
|
|
3321
|
-
}
|
|
3306
|
+
toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
|
|
3307
|
+
toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
|
|
3308
|
+
toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
|
|
3309
|
+
toggleClass(this.overlayElement, 'dv-drop-target-right', isRight);
|
|
3310
|
+
toggleClass(this.overlayElement, 'dv-drop-target-top', isTop);
|
|
3311
|
+
toggleClass(this.overlayElement, 'dv-drop-target-bottom', isBottom);
|
|
3312
|
+
toggleClass(this.overlayElement, 'dv-drop-target-center', quadrant === 'center');
|
|
3322
3313
|
}
|
|
3323
3314
|
calculateQuadrant(overlayType, x, y, width, height) {
|
|
3324
|
-
var _a, _b
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3327
|
-
const value = numberOrFallback((_f = (_e = (_d = this.options) === null || _d === void 0 ? void 0 : _d.overlayModel) === null || _e === void 0 ? void 0 : _e.activationSize) === null || _f === void 0 ? void 0 : _f.value, 20);
|
|
3315
|
+
var _a, _b;
|
|
3316
|
+
const activationSizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) !== null && _b !== void 0 ? _b : DEFAULT_ACTIVATION_SIZE;
|
|
3317
|
+
const isPercentage = activationSizeOptions.type === 'percentage';
|
|
3328
3318
|
if (isPercentage) {
|
|
3329
|
-
return calculateQuadrantAsPercentage(overlayType, x, y, width, height, value);
|
|
3319
|
+
return calculateQuadrantAsPercentage(overlayType, x, y, width, height, activationSizeOptions.value);
|
|
3330
3320
|
}
|
|
3331
|
-
return calculateQuadrantAsPixels(overlayType, x, y, width, height, value);
|
|
3321
|
+
return calculateQuadrantAsPixels(overlayType, x, y, width, height, activationSizeOptions.value);
|
|
3332
3322
|
}
|
|
3333
3323
|
removeDropTarget() {
|
|
3334
3324
|
if (this.targetElement) {
|
|
@@ -4520,6 +4510,21 @@ class Resizable extends CompositeDisposable {
|
|
|
4520
4510
|
if (this.disableResizing) {
|
|
4521
4511
|
return;
|
|
4522
4512
|
}
|
|
4513
|
+
if (!this._element.offsetParent) {
|
|
4514
|
+
/**
|
|
4515
|
+
* offsetParent === null is equivalent to display: none being set on the element or one
|
|
4516
|
+
* of it's parents. In the display: none case the size will become (0, 0) which we do
|
|
4517
|
+
* not want to propagate.
|
|
4518
|
+
*
|
|
4519
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
|
|
4520
|
+
*
|
|
4521
|
+
* You could use checkVisibility() but at the time of writing it's not supported across
|
|
4522
|
+
* all Browsers
|
|
4523
|
+
*
|
|
4524
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
|
|
4525
|
+
*/
|
|
4526
|
+
return;
|
|
4527
|
+
}
|
|
4523
4528
|
if (!isInDocument(this._element)) {
|
|
4524
4529
|
/**
|
|
4525
4530
|
* since the event is dispatched through requestAnimationFrame there is a small chance
|
|
@@ -6528,6 +6533,10 @@ class OverlayRenderContainer extends CompositeDisposable {
|
|
|
6528
6533
|
}
|
|
6529
6534
|
}
|
|
6530
6535
|
|
|
6536
|
+
const DEFAULT_ROOT_OVERLAY_MODEL = {
|
|
6537
|
+
activationSize: { type: 'pixels', value: 10 },
|
|
6538
|
+
size: { type: 'pixels', value: 20 },
|
|
6539
|
+
};
|
|
6531
6540
|
function getTheme(element) {
|
|
6532
6541
|
function toClassList(element) {
|
|
6533
6542
|
const list = [];
|
|
@@ -6572,7 +6581,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
6572
6581
|
return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisibile';
|
|
6573
6582
|
}
|
|
6574
6583
|
constructor(options) {
|
|
6575
|
-
var _a;
|
|
6584
|
+
var _a, _b;
|
|
6576
6585
|
super({
|
|
6577
6586
|
proportionalLayout: true,
|
|
6578
6587
|
orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
|
|
@@ -6636,7 +6645,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
6636
6645
|
!this.options.watermarkFrameworkComponent) {
|
|
6637
6646
|
this.options.watermarkComponent = Watermark;
|
|
6638
6647
|
}
|
|
6639
|
-
|
|
6648
|
+
this._rootDropTarget = new Droptarget(this.element, {
|
|
6640
6649
|
canDisplayOverlay: (event, position) => {
|
|
6641
6650
|
const data = getPanelData();
|
|
6642
6651
|
if (data) {
|
|
@@ -6669,12 +6678,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
6669
6678
|
return false;
|
|
6670
6679
|
},
|
|
6671
6680
|
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
6672
|
-
overlayModel:
|
|
6673
|
-
activationSize: { type: 'pixels', value: 10 },
|
|
6674
|
-
size: { type: 'pixels', value: 20 },
|
|
6675
|
-
},
|
|
6681
|
+
overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
|
|
6676
6682
|
});
|
|
6677
|
-
this.addDisposables(
|
|
6683
|
+
this.addDisposables(this._rootDropTarget.onDrop((event) => {
|
|
6678
6684
|
var _a;
|
|
6679
6685
|
const data = getPanelData();
|
|
6680
6686
|
if (data) {
|
|
@@ -6683,7 +6689,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
6683
6689
|
else {
|
|
6684
6690
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
6685
6691
|
}
|
|
6686
|
-
}),
|
|
6692
|
+
}), this._rootDropTarget);
|
|
6687
6693
|
this._api = new DockviewApi(this);
|
|
6688
6694
|
this.updateWatermark();
|
|
6689
6695
|
}
|
|
@@ -6846,15 +6852,17 @@ class DockviewComponent extends BaseGrid {
|
|
|
6846
6852
|
}
|
|
6847
6853
|
updateOptions(options) {
|
|
6848
6854
|
var _a, _b;
|
|
6849
|
-
const
|
|
6855
|
+
const changed_orientation = typeof options.orientation === 'string' &&
|
|
6850
6856
|
this.gridview.orientation !== options.orientation;
|
|
6851
|
-
const
|
|
6857
|
+
const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
|
|
6852
6858
|
options.floatingGroupBounds !== this.options.floatingGroupBounds;
|
|
6859
|
+
const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
|
|
6860
|
+
options.rootOverlayModel !== this.options.rootOverlayModel;
|
|
6853
6861
|
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
6854
|
-
if (
|
|
6862
|
+
if (changed_orientation) {
|
|
6855
6863
|
this.gridview.orientation = options.orientation;
|
|
6856
6864
|
}
|
|
6857
|
-
if (
|
|
6865
|
+
if (changed_floatingGroupBounds) {
|
|
6858
6866
|
for (const group of this._floatingGroups) {
|
|
6859
6867
|
switch (this.options.floatingGroupBounds) {
|
|
6860
6868
|
case 'boundedWithinViewport':
|
|
@@ -6876,6 +6884,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
6876
6884
|
group.overlay.setBounds({});
|
|
6877
6885
|
}
|
|
6878
6886
|
}
|
|
6887
|
+
if (changed_rootOverlayOptions) {
|
|
6888
|
+
this._rootDropTarget.setOverlayModel(options.rootOverlayModel);
|
|
6889
|
+
}
|
|
6879
6890
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
6880
6891
|
}
|
|
6881
6892
|
layout(width, height, forceResize) {
|
|
@@ -8851,6 +8862,7 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
8851
8862
|
floatingGroupBounds: props.floatingGroupBounds,
|
|
8852
8863
|
defaultRenderer: props.defaultRenderer,
|
|
8853
8864
|
debug: props.debug,
|
|
8865
|
+
rootOverlayModel: props.rootOverlayModel,
|
|
8854
8866
|
});
|
|
8855
8867
|
const { clientWidth, clientHeight } = domRef.current;
|
|
8856
8868
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -8958,6 +8970,14 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
8958
8970
|
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
8959
8971
|
});
|
|
8960
8972
|
}, [props.leftHeaderActionsComponent]);
|
|
8973
|
+
React.useEffect(() => {
|
|
8974
|
+
if (!dockviewRef.current) {
|
|
8975
|
+
return;
|
|
8976
|
+
}
|
|
8977
|
+
dockviewRef.current.updateOptions({
|
|
8978
|
+
rootOverlayModel: props.rootOverlayModel,
|
|
8979
|
+
});
|
|
8980
|
+
}, [props.rootOverlayModel]);
|
|
8961
8981
|
React.useEffect(() => {
|
|
8962
8982
|
if (!dockviewRef.current) {
|
|
8963
8983
|
return;
|