dockview-core 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.
Files changed (58) hide show
  1. package/dist/cjs/dnd/droptarget.d.ts +11 -12
  2. package/dist/cjs/dnd/droptarget.d.ts.map +1 -1
  3. package/dist/cjs/dnd/droptarget.js +37 -47
  4. package/dist/cjs/dnd/droptarget.js.map +1 -1
  5. package/dist/cjs/dockview/dockviewComponent.d.ts +2 -1
  6. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  7. package/dist/cjs/dockview/dockviewComponent.js +18 -12
  8. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  9. package/dist/cjs/dockview/options.d.ts +2 -1
  10. package/dist/cjs/dockview/options.d.ts.map +1 -1
  11. package/dist/cjs/dockview/options.js.map +1 -1
  12. package/dist/cjs/index.d.ts +1 -1
  13. package/dist/cjs/index.d.ts.map +1 -1
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/resizable.d.ts.map +1 -1
  16. package/dist/cjs/resizable.js +15 -0
  17. package/dist/cjs/resizable.js.map +1 -1
  18. package/dist/dockview-core.amd.js +72 -61
  19. package/dist/dockview-core.amd.js.map +1 -1
  20. package/dist/dockview-core.amd.min.js +2 -2
  21. package/dist/dockview-core.amd.min.js.map +1 -1
  22. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  23. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  24. package/dist/dockview-core.amd.noStyle.js +71 -60
  25. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  26. package/dist/dockview-core.cjs.js +72 -61
  27. package/dist/dockview-core.cjs.js.map +1 -1
  28. package/dist/dockview-core.esm.js +72 -61
  29. package/dist/dockview-core.esm.js.map +1 -1
  30. package/dist/dockview-core.esm.min.js +2 -2
  31. package/dist/dockview-core.esm.min.js.map +1 -1
  32. package/dist/dockview-core.js +72 -61
  33. package/dist/dockview-core.js.map +1 -1
  34. package/dist/dockview-core.min.js +2 -2
  35. package/dist/dockview-core.min.js.map +1 -1
  36. package/dist/dockview-core.min.noStyle.js +2 -2
  37. package/dist/dockview-core.min.noStyle.js.map +1 -1
  38. package/dist/dockview-core.noStyle.js +71 -60
  39. package/dist/dockview-core.noStyle.js.map +1 -1
  40. package/dist/esm/dnd/droptarget.d.ts +11 -12
  41. package/dist/esm/dnd/droptarget.d.ts.map +1 -1
  42. package/dist/esm/dnd/droptarget.js +37 -47
  43. package/dist/esm/dnd/droptarget.js.map +1 -1
  44. package/dist/esm/dockview/dockviewComponent.d.ts +2 -1
  45. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  46. package/dist/esm/dockview/dockviewComponent.js +19 -13
  47. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  48. package/dist/esm/dockview/options.d.ts +2 -1
  49. package/dist/esm/dockview/options.d.ts.map +1 -1
  50. package/dist/esm/dockview/options.js.map +1 -1
  51. package/dist/esm/index.d.ts +1 -1
  52. package/dist/esm/index.d.ts.map +1 -1
  53. package/dist/esm/index.js.map +1 -1
  54. package/dist/esm/resizable.d.ts.map +1 -1
  55. package/dist/esm/resizable.js +15 -0
  56. package/dist/esm/resizable.js.map +1 -1
  57. package/dist/styles/dockview.css +5 -5
  58. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.9.0
3
+ * @version 1.9.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -3082,9 +3082,6 @@
3082
3082
  }
3083
3083
  }
3084
3084
 
3085
- function numberOrFallback(maybeNumber, fallback) {
3086
- return typeof maybeNumber === 'number' ? maybeNumber : fallback;
3087
- }
3088
3085
  function directionToPosition(direction) {
3089
3086
  switch (direction) {
3090
3087
  case 'above':
@@ -3117,6 +3114,16 @@
3117
3114
  throw new Error(`invalid position '${position}'`);
3118
3115
  }
3119
3116
  }
3117
+ const DEFAULT_ACTIVATION_SIZE = {
3118
+ value: 20,
3119
+ type: 'percentage',
3120
+ };
3121
+ const DEFAULT_SIZE = {
3122
+ value: 50,
3123
+ type: 'percentage',
3124
+ };
3125
+ const SMALL_WIDTH_BOUNDARY = 100;
3126
+ const SMALL_HEIGHT_BOUNDARY = 100;
3120
3127
  class Droptarget extends CompositeDisposable {
3121
3128
  get state() {
3122
3129
  return this._state;
@@ -3177,7 +3184,7 @@
3177
3184
  this.element.append(this.targetElement);
3178
3185
  }
3179
3186
  this.toggleClasses(quadrant, width, height);
3180
- this.setState(quadrant);
3187
+ this._state = quadrant;
3181
3188
  },
3182
3189
  onDragLeave: () => {
3183
3190
  this.removeDropTarget();
@@ -3202,6 +3209,9 @@
3202
3209
  setTargetZones(acceptedTargetZones) {
3203
3210
  this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
3204
3211
  }
3212
+ setOverlayModel(model) {
3213
+ this.options.overlayModel = model;
3214
+ }
3205
3215
  dispose() {
3206
3216
  this.removeDropTarget();
3207
3217
  super.dispose();
@@ -3213,19 +3223,19 @@
3213
3223
  event[Droptarget.USED_EVENT_ID] = true;
3214
3224
  }
3215
3225
  /**
3216
- * Check is the event has already been used by another instance od DropTarget
3226
+ * Check is the event has already been used by another instance of DropTarget
3217
3227
  */
3218
3228
  isAlreadyUsed(event) {
3219
3229
  const value = event[Droptarget.USED_EVENT_ID];
3220
3230
  return typeof value === 'boolean' && value;
3221
3231
  }
3222
3232
  toggleClasses(quadrant, width, height) {
3223
- var _a, _b, _c, _d;
3233
+ var _a, _b;
3224
3234
  if (!this.overlayElement) {
3225
3235
  return;
3226
3236
  }
3227
- const isSmallX = width < 100;
3228
- const isSmallY = height < 100;
3237
+ const isSmallX = width < SMALL_WIDTH_BOUNDARY;
3238
+ const isSmallY = height < SMALL_HEIGHT_BOUNDARY;
3229
3239
  const isLeft = quadrant === 'left';
3230
3240
  const isRight = quadrant === 'right';
3231
3241
  const isTop = quadrant === 'top';
@@ -3234,20 +3244,17 @@
3234
3244
  const leftClass = !isSmallX && isLeft;
3235
3245
  const topClass = !isSmallY && isTop;
3236
3246
  const bottomClass = !isSmallY && isBottom;
3237
- let size = 0.5;
3238
- if (((_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.size) === null || _b === void 0 ? void 0 : _b.type) === 'percentage') {
3239
- size = clamp(this.options.overlayModel.size.value, 0, 100) / 100;
3247
+ let size = 1;
3248
+ const sizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : DEFAULT_SIZE;
3249
+ if (sizeOptions.type === 'percentage') {
3250
+ size = clamp(sizeOptions.value, 0, 100) / 100;
3240
3251
  }
3241
- if (((_d = (_c = this.options.overlayModel) === null || _c === void 0 ? void 0 : _c.size) === null || _d === void 0 ? void 0 : _d.type) === 'pixels') {
3252
+ else {
3242
3253
  if (rightClass || leftClass) {
3243
- size =
3244
- clamp(0, this.options.overlayModel.size.value, width) /
3245
- width;
3254
+ size = clamp(0, sizeOptions.value, width) / width;
3246
3255
  }
3247
3256
  if (topClass || bottomClass) {
3248
- size =
3249
- clamp(0, this.options.overlayModel.size.value, height) /
3250
- height;
3257
+ size = clamp(0, sizeOptions.value, height) / height;
3251
3258
  }
3252
3259
  }
3253
3260
  const translate = (1 - size) / 2;
@@ -3269,39 +3276,22 @@
3269
3276
  transform = '';
3270
3277
  }
3271
3278
  this.overlayElement.style.transform = transform;
3272
- toggleClass(this.overlayElement, 'small-right', isSmallX && isRight);
3273
- toggleClass(this.overlayElement, 'small-left', isSmallX && isLeft);
3274
- toggleClass(this.overlayElement, 'small-top', isSmallY && isTop);
3275
- toggleClass(this.overlayElement, 'small-bottom', isSmallY && isBottom);
3276
- }
3277
- setState(quadrant) {
3278
- switch (quadrant) {
3279
- case 'top':
3280
- this._state = 'top';
3281
- break;
3282
- case 'left':
3283
- this._state = 'left';
3284
- break;
3285
- case 'bottom':
3286
- this._state = 'bottom';
3287
- break;
3288
- case 'right':
3289
- this._state = 'right';
3290
- break;
3291
- case 'center':
3292
- this._state = 'center';
3293
- break;
3294
- }
3279
+ toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
3280
+ toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
3281
+ toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
3282
+ toggleClass(this.overlayElement, 'dv-drop-target-right', isRight);
3283
+ toggleClass(this.overlayElement, 'dv-drop-target-top', isTop);
3284
+ toggleClass(this.overlayElement, 'dv-drop-target-bottom', isBottom);
3285
+ toggleClass(this.overlayElement, 'dv-drop-target-center', quadrant === 'center');
3295
3286
  }
3296
3287
  calculateQuadrant(overlayType, x, y, width, height) {
3297
- var _a, _b, _c, _d, _e, _f;
3298
- const isPercentage = ((_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) === undefined ||
3299
- ((_c = (_b = this.options.overlayModel) === null || _b === void 0 ? void 0 : _b.activationSize) === null || _c === void 0 ? void 0 : _c.type) === 'percentage';
3300
- 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);
3288
+ var _a, _b;
3289
+ const activationSizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) !== null && _b !== void 0 ? _b : DEFAULT_ACTIVATION_SIZE;
3290
+ const isPercentage = activationSizeOptions.type === 'percentage';
3301
3291
  if (isPercentage) {
3302
- return calculateQuadrantAsPercentage(overlayType, x, y, width, height, value);
3292
+ return calculateQuadrantAsPercentage(overlayType, x, y, width, height, activationSizeOptions.value);
3303
3293
  }
3304
- return calculateQuadrantAsPixels(overlayType, x, y, width, height, value);
3294
+ return calculateQuadrantAsPixels(overlayType, x, y, width, height, activationSizeOptions.value);
3305
3295
  }
3306
3296
  removeDropTarget() {
3307
3297
  if (this.targetElement) {
@@ -4493,6 +4483,21 @@
4493
4483
  if (this.disableResizing) {
4494
4484
  return;
4495
4485
  }
4486
+ if (!this._element.offsetParent) {
4487
+ /**
4488
+ * offsetParent === null is equivalent to display: none being set on the element or one
4489
+ * of it's parents. In the display: none case the size will become (0, 0) which we do
4490
+ * not want to propagate.
4491
+ *
4492
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
4493
+ *
4494
+ * You could use checkVisibility() but at the time of writing it's not supported across
4495
+ * all Browsers
4496
+ *
4497
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
4498
+ */
4499
+ return;
4500
+ }
4496
4501
  if (!isInDocument(this._element)) {
4497
4502
  /**
4498
4503
  * since the event is dispatched through requestAnimationFrame there is a small chance
@@ -6501,6 +6506,10 @@
6501
6506
  }
6502
6507
  }
6503
6508
 
6509
+ const DEFAULT_ROOT_OVERLAY_MODEL = {
6510
+ activationSize: { type: 'pixels', value: 10 },
6511
+ size: { type: 'pixels', value: 20 },
6512
+ };
6504
6513
  function getTheme(element) {
6505
6514
  function toClassList(element) {
6506
6515
  const list = [];
@@ -6545,7 +6554,7 @@
6545
6554
  return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisibile';
6546
6555
  }
6547
6556
  constructor(options) {
6548
- var _a;
6557
+ var _a, _b;
6549
6558
  super({
6550
6559
  proportionalLayout: true,
6551
6560
  orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.HORIZONTAL,
@@ -6609,7 +6618,7 @@
6609
6618
  !this.options.watermarkFrameworkComponent) {
6610
6619
  this.options.watermarkComponent = Watermark;
6611
6620
  }
6612
- const dropTarget = new Droptarget(this.element, {
6621
+ this._rootDropTarget = new Droptarget(this.element, {
6613
6622
  canDisplayOverlay: (event, position) => {
6614
6623
  const data = getPanelData();
6615
6624
  if (data) {
@@ -6642,12 +6651,9 @@
6642
6651
  return false;
6643
6652
  },
6644
6653
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
6645
- overlayModel: {
6646
- activationSize: { type: 'pixels', value: 10 },
6647
- size: { type: 'pixels', value: 20 },
6648
- },
6654
+ overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
6649
6655
  });
6650
- this.addDisposables(dropTarget.onDrop((event) => {
6656
+ this.addDisposables(this._rootDropTarget.onDrop((event) => {
6651
6657
  var _a;
6652
6658
  const data = getPanelData();
6653
6659
  if (data) {
@@ -6656,7 +6662,7 @@
6656
6662
  else {
6657
6663
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
6658
6664
  }
6659
- }), dropTarget);
6665
+ }), this._rootDropTarget);
6660
6666
  this._api = new DockviewApi(this);
6661
6667
  this.updateWatermark();
6662
6668
  }
@@ -6819,15 +6825,17 @@
6819
6825
  }
6820
6826
  updateOptions(options) {
6821
6827
  var _a, _b;
6822
- const hasOrientationChanged = typeof options.orientation === 'string' &&
6828
+ const changed_orientation = typeof options.orientation === 'string' &&
6823
6829
  this.gridview.orientation !== options.orientation;
6824
- const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
6830
+ const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
6825
6831
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
6832
+ const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
6833
+ options.rootOverlayModel !== this.options.rootOverlayModel;
6826
6834
  this._options = Object.assign(Object.assign({}, this.options), options);
6827
- if (hasOrientationChanged) {
6835
+ if (changed_orientation) {
6828
6836
  this.gridview.orientation = options.orientation;
6829
6837
  }
6830
- if (hasFloatingGroupOptionsChanged) {
6838
+ if (changed_floatingGroupBounds) {
6831
6839
  for (const group of this._floatingGroups) {
6832
6840
  switch (this.options.floatingGroupBounds) {
6833
6841
  case 'boundedWithinViewport':
@@ -6849,6 +6857,9 @@
6849
6857
  group.overlay.setBounds({});
6850
6858
  }
6851
6859
  }
6860
+ if (changed_rootOverlayOptions) {
6861
+ this._rootDropTarget.setOverlayModel(options.rootOverlayModel);
6862
+ }
6852
6863
  this.layout(this.gridview.width, this.gridview.height, true);
6853
6864
  }
6854
6865
  layout(width, height, forceResize) {