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.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
|
*/
|
|
@@ -3132,9 +3132,6 @@
|
|
|
3132
3132
|
}
|
|
3133
3133
|
}
|
|
3134
3134
|
|
|
3135
|
-
function numberOrFallback(maybeNumber, fallback) {
|
|
3136
|
-
return typeof maybeNumber === 'number' ? maybeNumber : fallback;
|
|
3137
|
-
}
|
|
3138
3135
|
function directionToPosition(direction) {
|
|
3139
3136
|
switch (direction) {
|
|
3140
3137
|
case 'above':
|
|
@@ -3167,6 +3164,16 @@
|
|
|
3167
3164
|
throw new Error(`invalid position '${position}'`);
|
|
3168
3165
|
}
|
|
3169
3166
|
}
|
|
3167
|
+
const DEFAULT_ACTIVATION_SIZE = {
|
|
3168
|
+
value: 20,
|
|
3169
|
+
type: 'percentage',
|
|
3170
|
+
};
|
|
3171
|
+
const DEFAULT_SIZE = {
|
|
3172
|
+
value: 50,
|
|
3173
|
+
type: 'percentage',
|
|
3174
|
+
};
|
|
3175
|
+
const SMALL_WIDTH_BOUNDARY = 100;
|
|
3176
|
+
const SMALL_HEIGHT_BOUNDARY = 100;
|
|
3170
3177
|
class Droptarget extends CompositeDisposable {
|
|
3171
3178
|
get state() {
|
|
3172
3179
|
return this._state;
|
|
@@ -3227,7 +3234,7 @@
|
|
|
3227
3234
|
this.element.append(this.targetElement);
|
|
3228
3235
|
}
|
|
3229
3236
|
this.toggleClasses(quadrant, width, height);
|
|
3230
|
-
this.
|
|
3237
|
+
this._state = quadrant;
|
|
3231
3238
|
},
|
|
3232
3239
|
onDragLeave: () => {
|
|
3233
3240
|
this.removeDropTarget();
|
|
@@ -3252,6 +3259,9 @@
|
|
|
3252
3259
|
setTargetZones(acceptedTargetZones) {
|
|
3253
3260
|
this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
|
|
3254
3261
|
}
|
|
3262
|
+
setOverlayModel(model) {
|
|
3263
|
+
this.options.overlayModel = model;
|
|
3264
|
+
}
|
|
3255
3265
|
dispose() {
|
|
3256
3266
|
this.removeDropTarget();
|
|
3257
3267
|
super.dispose();
|
|
@@ -3263,19 +3273,19 @@
|
|
|
3263
3273
|
event[Droptarget.USED_EVENT_ID] = true;
|
|
3264
3274
|
}
|
|
3265
3275
|
/**
|
|
3266
|
-
* Check is the event has already been used by another instance
|
|
3276
|
+
* Check is the event has already been used by another instance of DropTarget
|
|
3267
3277
|
*/
|
|
3268
3278
|
isAlreadyUsed(event) {
|
|
3269
3279
|
const value = event[Droptarget.USED_EVENT_ID];
|
|
3270
3280
|
return typeof value === 'boolean' && value;
|
|
3271
3281
|
}
|
|
3272
3282
|
toggleClasses(quadrant, width, height) {
|
|
3273
|
-
var _a, _b
|
|
3283
|
+
var _a, _b;
|
|
3274
3284
|
if (!this.overlayElement) {
|
|
3275
3285
|
return;
|
|
3276
3286
|
}
|
|
3277
|
-
const isSmallX = width <
|
|
3278
|
-
const isSmallY = height <
|
|
3287
|
+
const isSmallX = width < SMALL_WIDTH_BOUNDARY;
|
|
3288
|
+
const isSmallY = height < SMALL_HEIGHT_BOUNDARY;
|
|
3279
3289
|
const isLeft = quadrant === 'left';
|
|
3280
3290
|
const isRight = quadrant === 'right';
|
|
3281
3291
|
const isTop = quadrant === 'top';
|
|
@@ -3284,20 +3294,17 @@
|
|
|
3284
3294
|
const leftClass = !isSmallX && isLeft;
|
|
3285
3295
|
const topClass = !isSmallY && isTop;
|
|
3286
3296
|
const bottomClass = !isSmallY && isBottom;
|
|
3287
|
-
let size =
|
|
3288
|
-
|
|
3289
|
-
|
|
3297
|
+
let size = 1;
|
|
3298
|
+
const sizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : DEFAULT_SIZE;
|
|
3299
|
+
if (sizeOptions.type === 'percentage') {
|
|
3300
|
+
size = clamp(sizeOptions.value, 0, 100) / 100;
|
|
3290
3301
|
}
|
|
3291
|
-
|
|
3302
|
+
else {
|
|
3292
3303
|
if (rightClass || leftClass) {
|
|
3293
|
-
size =
|
|
3294
|
-
clamp(0, this.options.overlayModel.size.value, width) /
|
|
3295
|
-
width;
|
|
3304
|
+
size = clamp(0, sizeOptions.value, width) / width;
|
|
3296
3305
|
}
|
|
3297
3306
|
if (topClass || bottomClass) {
|
|
3298
|
-
size =
|
|
3299
|
-
clamp(0, this.options.overlayModel.size.value, height) /
|
|
3300
|
-
height;
|
|
3307
|
+
size = clamp(0, sizeOptions.value, height) / height;
|
|
3301
3308
|
}
|
|
3302
3309
|
}
|
|
3303
3310
|
const translate = (1 - size) / 2;
|
|
@@ -3319,39 +3326,22 @@
|
|
|
3319
3326
|
transform = '';
|
|
3320
3327
|
}
|
|
3321
3328
|
this.overlayElement.style.transform = transform;
|
|
3322
|
-
toggleClass(this.overlayElement, 'small-
|
|
3323
|
-
toggleClass(this.overlayElement, 'small-
|
|
3324
|
-
toggleClass(this.overlayElement, '
|
|
3325
|
-
toggleClass(this.overlayElement, '
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
case 'top':
|
|
3330
|
-
this._state = 'top';
|
|
3331
|
-
break;
|
|
3332
|
-
case 'left':
|
|
3333
|
-
this._state = 'left';
|
|
3334
|
-
break;
|
|
3335
|
-
case 'bottom':
|
|
3336
|
-
this._state = 'bottom';
|
|
3337
|
-
break;
|
|
3338
|
-
case 'right':
|
|
3339
|
-
this._state = 'right';
|
|
3340
|
-
break;
|
|
3341
|
-
case 'center':
|
|
3342
|
-
this._state = 'center';
|
|
3343
|
-
break;
|
|
3344
|
-
}
|
|
3329
|
+
toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
|
|
3330
|
+
toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
|
|
3331
|
+
toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
|
|
3332
|
+
toggleClass(this.overlayElement, 'dv-drop-target-right', isRight);
|
|
3333
|
+
toggleClass(this.overlayElement, 'dv-drop-target-top', isTop);
|
|
3334
|
+
toggleClass(this.overlayElement, 'dv-drop-target-bottom', isBottom);
|
|
3335
|
+
toggleClass(this.overlayElement, 'dv-drop-target-center', quadrant === 'center');
|
|
3345
3336
|
}
|
|
3346
3337
|
calculateQuadrant(overlayType, x, y, width, height) {
|
|
3347
|
-
var _a, _b
|
|
3348
|
-
const
|
|
3349
|
-
|
|
3350
|
-
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);
|
|
3338
|
+
var _a, _b;
|
|
3339
|
+
const activationSizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) !== null && _b !== void 0 ? _b : DEFAULT_ACTIVATION_SIZE;
|
|
3340
|
+
const isPercentage = activationSizeOptions.type === 'percentage';
|
|
3351
3341
|
if (isPercentage) {
|
|
3352
|
-
return calculateQuadrantAsPercentage(overlayType, x, y, width, height, value);
|
|
3342
|
+
return calculateQuadrantAsPercentage(overlayType, x, y, width, height, activationSizeOptions.value);
|
|
3353
3343
|
}
|
|
3354
|
-
return calculateQuadrantAsPixels(overlayType, x, y, width, height, value);
|
|
3344
|
+
return calculateQuadrantAsPixels(overlayType, x, y, width, height, activationSizeOptions.value);
|
|
3355
3345
|
}
|
|
3356
3346
|
removeDropTarget() {
|
|
3357
3347
|
if (this.targetElement) {
|
|
@@ -4543,6 +4533,21 @@
|
|
|
4543
4533
|
if (this.disableResizing) {
|
|
4544
4534
|
return;
|
|
4545
4535
|
}
|
|
4536
|
+
if (!this._element.offsetParent) {
|
|
4537
|
+
/**
|
|
4538
|
+
* offsetParent === null is equivalent to display: none being set on the element or one
|
|
4539
|
+
* of it's parents. In the display: none case the size will become (0, 0) which we do
|
|
4540
|
+
* not want to propagate.
|
|
4541
|
+
*
|
|
4542
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
|
|
4543
|
+
*
|
|
4544
|
+
* You could use checkVisibility() but at the time of writing it's not supported across
|
|
4545
|
+
* all Browsers
|
|
4546
|
+
*
|
|
4547
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
|
|
4548
|
+
*/
|
|
4549
|
+
return;
|
|
4550
|
+
}
|
|
4546
4551
|
if (!isInDocument(this._element)) {
|
|
4547
4552
|
/**
|
|
4548
4553
|
* since the event is dispatched through requestAnimationFrame there is a small chance
|
|
@@ -6551,6 +6556,10 @@
|
|
|
6551
6556
|
}
|
|
6552
6557
|
}
|
|
6553
6558
|
|
|
6559
|
+
const DEFAULT_ROOT_OVERLAY_MODEL = {
|
|
6560
|
+
activationSize: { type: 'pixels', value: 10 },
|
|
6561
|
+
size: { type: 'pixels', value: 20 },
|
|
6562
|
+
};
|
|
6554
6563
|
function getTheme(element) {
|
|
6555
6564
|
function toClassList(element) {
|
|
6556
6565
|
const list = [];
|
|
@@ -6595,7 +6604,7 @@
|
|
|
6595
6604
|
return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisibile';
|
|
6596
6605
|
}
|
|
6597
6606
|
constructor(options) {
|
|
6598
|
-
var _a;
|
|
6607
|
+
var _a, _b;
|
|
6599
6608
|
super({
|
|
6600
6609
|
proportionalLayout: true,
|
|
6601
6610
|
orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.HORIZONTAL,
|
|
@@ -6659,7 +6668,7 @@
|
|
|
6659
6668
|
!this.options.watermarkFrameworkComponent) {
|
|
6660
6669
|
this.options.watermarkComponent = Watermark;
|
|
6661
6670
|
}
|
|
6662
|
-
|
|
6671
|
+
this._rootDropTarget = new Droptarget(this.element, {
|
|
6663
6672
|
canDisplayOverlay: (event, position) => {
|
|
6664
6673
|
const data = getPanelData();
|
|
6665
6674
|
if (data) {
|
|
@@ -6692,12 +6701,9 @@
|
|
|
6692
6701
|
return false;
|
|
6693
6702
|
},
|
|
6694
6703
|
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
6695
|
-
overlayModel:
|
|
6696
|
-
activationSize: { type: 'pixels', value: 10 },
|
|
6697
|
-
size: { type: 'pixels', value: 20 },
|
|
6698
|
-
},
|
|
6704
|
+
overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
|
|
6699
6705
|
});
|
|
6700
|
-
this.addDisposables(
|
|
6706
|
+
this.addDisposables(this._rootDropTarget.onDrop((event) => {
|
|
6701
6707
|
var _a;
|
|
6702
6708
|
const data = getPanelData();
|
|
6703
6709
|
if (data) {
|
|
@@ -6706,7 +6712,7 @@
|
|
|
6706
6712
|
else {
|
|
6707
6713
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
6708
6714
|
}
|
|
6709
|
-
}),
|
|
6715
|
+
}), this._rootDropTarget);
|
|
6710
6716
|
this._api = new DockviewApi(this);
|
|
6711
6717
|
this.updateWatermark();
|
|
6712
6718
|
}
|
|
@@ -6869,15 +6875,17 @@
|
|
|
6869
6875
|
}
|
|
6870
6876
|
updateOptions(options) {
|
|
6871
6877
|
var _a, _b;
|
|
6872
|
-
const
|
|
6878
|
+
const changed_orientation = typeof options.orientation === 'string' &&
|
|
6873
6879
|
this.gridview.orientation !== options.orientation;
|
|
6874
|
-
const
|
|
6880
|
+
const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
|
|
6875
6881
|
options.floatingGroupBounds !== this.options.floatingGroupBounds;
|
|
6882
|
+
const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
|
|
6883
|
+
options.rootOverlayModel !== this.options.rootOverlayModel;
|
|
6876
6884
|
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
6877
|
-
if (
|
|
6885
|
+
if (changed_orientation) {
|
|
6878
6886
|
this.gridview.orientation = options.orientation;
|
|
6879
6887
|
}
|
|
6880
|
-
if (
|
|
6888
|
+
if (changed_floatingGroupBounds) {
|
|
6881
6889
|
for (const group of this._floatingGroups) {
|
|
6882
6890
|
switch (this.options.floatingGroupBounds) {
|
|
6883
6891
|
case 'boundedWithinViewport':
|
|
@@ -6899,6 +6907,9 @@
|
|
|
6899
6907
|
group.overlay.setBounds({});
|
|
6900
6908
|
}
|
|
6901
6909
|
}
|
|
6910
|
+
if (changed_rootOverlayOptions) {
|
|
6911
|
+
this._rootDropTarget.setOverlayModel(options.rootOverlayModel);
|
|
6912
|
+
}
|
|
6902
6913
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
6903
6914
|
}
|
|
6904
6915
|
layout(width, height, forceResize) {
|
|
@@ -8874,6 +8885,7 @@
|
|
|
8874
8885
|
floatingGroupBounds: props.floatingGroupBounds,
|
|
8875
8886
|
defaultRenderer: props.defaultRenderer,
|
|
8876
8887
|
debug: props.debug,
|
|
8888
|
+
rootOverlayModel: props.rootOverlayModel,
|
|
8877
8889
|
});
|
|
8878
8890
|
const { clientWidth, clientHeight } = domRef.current;
|
|
8879
8891
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -8981,6 +8993,14 @@
|
|
|
8981
8993
|
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
8982
8994
|
});
|
|
8983
8995
|
}, [props.leftHeaderActionsComponent]);
|
|
8996
|
+
React__namespace.useEffect(() => {
|
|
8997
|
+
if (!dockviewRef.current) {
|
|
8998
|
+
return;
|
|
8999
|
+
}
|
|
9000
|
+
dockviewRef.current.updateOptions({
|
|
9001
|
+
rootOverlayModel: props.rootOverlayModel,
|
|
9002
|
+
});
|
|
9003
|
+
}, [props.rootOverlayModel]);
|
|
8984
9004
|
React__namespace.useEffect(() => {
|
|
8985
9005
|
if (!dockviewRef.current) {
|
|
8986
9006
|
return;
|