dockview-core 1.9.0 → 1.9.2

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 (68) 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/components/panel/content.js +2 -2
  6. package/dist/cjs/dockview/components/panel/content.js.map +1 -1
  7. package/dist/cjs/dockview/dockviewComponent.d.ts +2 -1
  8. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  9. package/dist/cjs/dockview/dockviewComponent.js +19 -13
  10. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  11. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  12. package/dist/cjs/dockview/dockviewGroupPanelModel.js +1 -0
  13. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  14. package/dist/cjs/dockview/options.d.ts +4 -2
  15. package/dist/cjs/dockview/options.d.ts.map +1 -1
  16. package/dist/cjs/dockview/options.js.map +1 -1
  17. package/dist/cjs/index.d.ts +1 -1
  18. package/dist/cjs/index.d.ts.map +1 -1
  19. package/dist/cjs/index.js.map +1 -1
  20. package/dist/cjs/resizable.d.ts.map +1 -1
  21. package/dist/cjs/resizable.js +15 -0
  22. package/dist/cjs/resizable.js.map +1 -1
  23. package/dist/dockview-core.amd.js +76 -64
  24. package/dist/dockview-core.amd.js.map +1 -1
  25. package/dist/dockview-core.amd.min.js +2 -2
  26. package/dist/dockview-core.amd.min.js.map +1 -1
  27. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  28. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  29. package/dist/dockview-core.amd.noStyle.js +75 -63
  30. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  31. package/dist/dockview-core.cjs.js +76 -64
  32. package/dist/dockview-core.cjs.js.map +1 -1
  33. package/dist/dockview-core.esm.js +76 -64
  34. package/dist/dockview-core.esm.js.map +1 -1
  35. package/dist/dockview-core.esm.min.js +2 -2
  36. package/dist/dockview-core.esm.min.js.map +1 -1
  37. package/dist/dockview-core.js +76 -64
  38. package/dist/dockview-core.js.map +1 -1
  39. package/dist/dockview-core.min.js +2 -2
  40. package/dist/dockview-core.min.js.map +1 -1
  41. package/dist/dockview-core.min.noStyle.js +2 -2
  42. package/dist/dockview-core.min.noStyle.js.map +1 -1
  43. package/dist/dockview-core.noStyle.js +75 -63
  44. package/dist/dockview-core.noStyle.js.map +1 -1
  45. package/dist/esm/dnd/droptarget.d.ts +11 -12
  46. package/dist/esm/dnd/droptarget.d.ts.map +1 -1
  47. package/dist/esm/dnd/droptarget.js +37 -47
  48. package/dist/esm/dnd/droptarget.js.map +1 -1
  49. package/dist/esm/dockview/components/panel/content.js +2 -2
  50. package/dist/esm/dockview/components/panel/content.js.map +1 -1
  51. package/dist/esm/dockview/dockviewComponent.d.ts +2 -1
  52. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  53. package/dist/esm/dockview/dockviewComponent.js +20 -14
  54. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  55. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  56. package/dist/esm/dockview/dockviewGroupPanelModel.js +1 -0
  57. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  58. package/dist/esm/dockview/options.d.ts +4 -2
  59. package/dist/esm/dockview/options.d.ts.map +1 -1
  60. package/dist/esm/dockview/options.js.map +1 -1
  61. package/dist/esm/index.d.ts +1 -1
  62. package/dist/esm/index.d.ts.map +1 -1
  63. package/dist/esm/index.js.map +1 -1
  64. package/dist/esm/resizable.d.ts.map +1 -1
  65. package/dist/esm/resizable.js +15 -0
  66. package/dist/esm/resizable.js.map +1 -1
  67. package/dist/styles/dockview.css +5 -5
  68. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.9.0
3
+ * @version 1.9.2
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) {
@@ -3475,11 +3465,11 @@
3475
3465
  }
3476
3466
  closePanel() {
3477
3467
  if (this.panel) {
3478
- if (this.accessor.options.defaultRenderer === 'onlyWhenVisibile') {
3468
+ if (this.panel.api.renderer === 'onlyWhenVisibile') {
3479
3469
  this._element.removeChild(this.panel.view.content.element);
3480
3470
  }
3481
- this.panel = undefined;
3482
3471
  }
3472
+ this.panel = undefined;
3483
3473
  }
3484
3474
  dispose() {
3485
3475
  this.disposable.dispose();
@@ -4230,6 +4220,7 @@
4230
4220
  if (!skipSetGroupActive) {
4231
4221
  this.accessor.doSetGroupActive(this.groupPanel);
4232
4222
  }
4223
+ this.contentContainer.renderPanel(panel, { asActive: true });
4233
4224
  return;
4234
4225
  }
4235
4226
  this.doAddPanel(panel, options.index, skipSetPanelActive);
@@ -4493,6 +4484,21 @@
4493
4484
  if (this.disableResizing) {
4494
4485
  return;
4495
4486
  }
4487
+ if (!this._element.offsetParent) {
4488
+ /**
4489
+ * offsetParent === null is equivalent to display: none being set on the element or one
4490
+ * of it's parents. In the display: none case the size will become (0, 0) which we do
4491
+ * not want to propagate.
4492
+ *
4493
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
4494
+ *
4495
+ * You could use checkVisibility() but at the time of writing it's not supported across
4496
+ * all Browsers
4497
+ *
4498
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
4499
+ */
4500
+ return;
4501
+ }
4496
4502
  if (!isInDocument(this._element)) {
4497
4503
  /**
4498
4504
  * since the event is dispatched through requestAnimationFrame there is a small chance
@@ -6501,6 +6507,10 @@
6501
6507
  }
6502
6508
  }
6503
6509
 
6510
+ const DEFAULT_ROOT_OVERLAY_MODEL = {
6511
+ activationSize: { type: 'pixels', value: 10 },
6512
+ size: { type: 'pixels', value: 20 },
6513
+ };
6504
6514
  function getTheme(element) {
6505
6515
  function toClassList(element) {
6506
6516
  const list = [];
@@ -6545,7 +6555,7 @@
6545
6555
  return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisibile';
6546
6556
  }
6547
6557
  constructor(options) {
6548
- var _a;
6558
+ var _a, _b;
6549
6559
  super({
6550
6560
  proportionalLayout: true,
6551
6561
  orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : exports.Orientation.HORIZONTAL,
@@ -6609,7 +6619,7 @@
6609
6619
  !this.options.watermarkFrameworkComponent) {
6610
6620
  this.options.watermarkComponent = Watermark;
6611
6621
  }
6612
- const dropTarget = new Droptarget(this.element, {
6622
+ this._rootDropTarget = new Droptarget(this.element, {
6613
6623
  canDisplayOverlay: (event, position) => {
6614
6624
  const data = getPanelData();
6615
6625
  if (data) {
@@ -6642,12 +6652,9 @@
6642
6652
  return false;
6643
6653
  },
6644
6654
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
6645
- overlayModel: {
6646
- activationSize: { type: 'pixels', value: 10 },
6647
- size: { type: 'pixels', value: 20 },
6648
- },
6655
+ overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
6649
6656
  });
6650
- this.addDisposables(dropTarget.onDrop((event) => {
6657
+ this.addDisposables(this._rootDropTarget.onDrop((event) => {
6651
6658
  var _a;
6652
6659
  const data = getPanelData();
6653
6660
  if (data) {
@@ -6656,7 +6663,7 @@
6656
6663
  else {
6657
6664
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
6658
6665
  }
6659
- }), dropTarget);
6666
+ }), this._rootDropTarget);
6660
6667
  this._api = new DockviewApi(this);
6661
6668
  this.updateWatermark();
6662
6669
  }
@@ -6819,15 +6826,17 @@
6819
6826
  }
6820
6827
  updateOptions(options) {
6821
6828
  var _a, _b;
6822
- const hasOrientationChanged = typeof options.orientation === 'string' &&
6829
+ const changed_orientation = typeof options.orientation === 'string' &&
6823
6830
  this.gridview.orientation !== options.orientation;
6824
- const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
6831
+ const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
6825
6832
  options.floatingGroupBounds !== this.options.floatingGroupBounds;
6833
+ const changed_rootOverlayOptions = options.rootOverlayModel !== undefined &&
6834
+ options.rootOverlayModel !== this.options.rootOverlayModel;
6826
6835
  this._options = Object.assign(Object.assign({}, this.options), options);
6827
- if (hasOrientationChanged) {
6836
+ if (changed_orientation) {
6828
6837
  this.gridview.orientation = options.orientation;
6829
6838
  }
6830
- if (hasFloatingGroupOptionsChanged) {
6839
+ if (changed_floatingGroupBounds) {
6831
6840
  for (const group of this._floatingGroups) {
6832
6841
  switch (this.options.floatingGroupBounds) {
6833
6842
  case 'boundedWithinViewport':
@@ -6849,6 +6858,9 @@
6849
6858
  group.overlay.setBounds({});
6850
6859
  }
6851
6860
  }
6861
+ if (changed_rootOverlayOptions) {
6862
+ this._rootDropTarget.setOverlayModel(options.rootOverlayModel);
6863
+ }
6852
6864
  this.layout(this.gridview.width, this.gridview.height, true);
6853
6865
  }
6854
6866
  layout(width, height, forceResize) {
@@ -7230,7 +7242,7 @@
7230
7242
  }
7231
7243
  addGroup(options) {
7232
7244
  var _a;
7233
- const group = this.createGroup();
7245
+ const group = this.createGroup(options);
7234
7246
  if (options) {
7235
7247
  let referenceGroup;
7236
7248
  if (isGroupOptionsWithPanel(options)) {