@hpcc-js/phosphor 2.16.0 → 2.16.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/index.es6.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { select, Widget as Widget$1, HTMLWidget } from '@hpcc-js/common';
2
2
 
3
3
  var PKG_NAME = "@hpcc-js/phosphor";
4
- var PKG_VERSION = "2.16.0";
5
- var BUILD_VERSION = "2.104.1";
4
+ var PKG_VERSION = "2.16.1";
5
+ var BUILD_VERSION = "2.104.2";
6
6
 
7
7
  // Copyright (c) Jupyter Development Team.
8
8
  // Distributed under the terms of the Modified BSD License.
@@ -9690,6 +9690,15 @@ function __rest(s, e) {
9690
9690
  t[p[i]] = s[p[i]];
9691
9691
  }
9692
9692
  return t;
9693
+ }
9694
+
9695
+ /** @deprecated */
9696
+ function __spreadArrays() {
9697
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
9698
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
9699
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
9700
+ r[k] = a[j];
9701
+ return r;
9693
9702
  }
9694
9703
 
9695
9704
  // Copyright (c) Jupyter Development Team.
@@ -10159,7 +10168,6 @@ var BoxEngine;
10159
10168
  }
10160
10169
  })(BoxEngine || (BoxEngine = {}));
10161
10170
 
10162
- // Copyright (c) Jupyter Development Team.
10163
10171
  /**
10164
10172
  * An object which holds data related to an object's title.
10165
10173
  *
@@ -10167,6 +10175,8 @@ var BoxEngine;
10167
10175
  * A title object is intended to hold the data necessary to display a
10168
10176
  * header for a particular object. A common example is the `TabPanel`,
10169
10177
  * which uses the widget title to populate the tab for a child widget.
10178
+ *
10179
+ * It is the responsibility of the owner to call the title disposal.
10170
10180
  */
10171
10181
  var Title = /** @class */ (function () {
10172
10182
  /**
@@ -10183,6 +10193,7 @@ var Title = /** @class */ (function () {
10183
10193
  this._className = '';
10184
10194
  this._closable = false;
10185
10195
  this._changed = new Signal(this);
10196
+ this._isDisposed = false;
10186
10197
  this.owner = options.owner;
10187
10198
  if (options.label !== undefined) {
10188
10199
  this._label = options.label;
@@ -10504,6 +10515,29 @@ var Title = /** @class */ (function () {
10504
10515
  enumerable: true,
10505
10516
  configurable: true
10506
10517
  });
10518
+ Object.defineProperty(Title.prototype, "isDisposed", {
10519
+ /**
10520
+ * Test whether the title has been disposed.
10521
+ */
10522
+ get: function () {
10523
+ return this._isDisposed;
10524
+ },
10525
+ enumerable: true,
10526
+ configurable: true
10527
+ });
10528
+ /**
10529
+ * Dispose of the resources held by the title.
10530
+ *
10531
+ * #### Notes
10532
+ * It is the responsibility of the owner to call the title disposal.
10533
+ */
10534
+ Title.prototype.dispose = function () {
10535
+ if (this.isDisposed) {
10536
+ return;
10537
+ }
10538
+ this._isDisposed = true;
10539
+ Signal.clearData(this);
10540
+ };
10507
10541
  return Title;
10508
10542
  }());
10509
10543
 
@@ -10562,6 +10596,8 @@ var Widget = /** @class */ (function () {
10562
10596
  this._layout.dispose();
10563
10597
  this._layout = null;
10564
10598
  }
10599
+ // Dispose the title
10600
+ this.title.dispose();
10565
10601
  // Clear the extra data associated with the widget.
10566
10602
  Signal.clearData(this);
10567
10603
  MessageLoop.clearData(this);
@@ -12696,6 +12732,16 @@ var SplitLayout = /** @class */ (function (_super) {
12696
12732
  enumerable: true,
12697
12733
  configurable: true
12698
12734
  });
12735
+ /**
12736
+ * Get the absolute sizes of the widgets in the layout.
12737
+ *
12738
+ * @returns A new array of the absolute sizes of the widgets.
12739
+ *
12740
+ * This method **does not** measure the DOM nodes.
12741
+ */
12742
+ SplitLayout.prototype.absoluteSizes = function () {
12743
+ return this._sizers.map(function (sizer) { return sizer.size; });
12744
+ };
12699
12745
  /**
12700
12746
  * Get the relative sizes of the widgets in the layout.
12701
12747
  *
@@ -12714,13 +12760,16 @@ var SplitLayout = /** @class */ (function (_super) {
12714
12760
  * Set the relative sizes for the widgets in the layout.
12715
12761
  *
12716
12762
  * @param sizes - The relative sizes for the widgets in the panel.
12763
+ * @param update - Update the layout after setting relative sizes.
12764
+ * Default is True.
12717
12765
  *
12718
12766
  * #### Notes
12719
12767
  * Extra values are ignored, too few will yield an undefined layout.
12720
12768
  *
12721
12769
  * The actual geometry of the DOM nodes is updated asynchronously.
12722
12770
  */
12723
- SplitLayout.prototype.setRelativeSizes = function (sizes) {
12771
+ SplitLayout.prototype.setRelativeSizes = function (sizes, update) {
12772
+ if (update === void 0) { update = true; }
12724
12773
  // Copy the sizes and pad with zeros as needed.
12725
12774
  var n = this._sizers.length;
12726
12775
  var temp = sizes.slice(0, n);
@@ -12738,7 +12787,7 @@ var SplitLayout = /** @class */ (function (_super) {
12738
12787
  // Set the flag indicating the sizes are normalized.
12739
12788
  this._hasNormedSizes = true;
12740
12789
  // Trigger an update of the parent widget.
12741
- if (this.parent) {
12790
+ if (update && this.parent) {
12742
12791
  this.parent.update();
12743
12792
  }
12744
12793
  };
@@ -13509,6 +13558,7 @@ var SplitPanel$1 = /** @class */ (function (_super) {
13509
13558
  function SplitPanel(options) {
13510
13559
  if (options === void 0) { options = {}; }
13511
13560
  var _this = _super.call(this, { layout: Private$e.createLayout(options) }) || this;
13561
+ _this._handleMoved = new Signal(_this);
13512
13562
  _this._pressData = null;
13513
13563
  _this.addClass('lm-SplitPanel');
13514
13564
  /* <DEPRECATED> */
@@ -13593,6 +13643,16 @@ var SplitPanel$1 = /** @class */ (function (_super) {
13593
13643
  enumerable: true,
13594
13644
  configurable: true
13595
13645
  });
13646
+ Object.defineProperty(SplitPanel.prototype, "handleMoved", {
13647
+ /**
13648
+ * A signal emitted when a split handle has moved.
13649
+ */
13650
+ get: function () {
13651
+ return this._handleMoved;
13652
+ },
13653
+ enumerable: true,
13654
+ configurable: true
13655
+ });
13596
13656
  Object.defineProperty(SplitPanel.prototype, "handles", {
13597
13657
  /**
13598
13658
  * A read-only array of the split handles in the panel.
@@ -13621,14 +13681,17 @@ var SplitPanel$1 = /** @class */ (function (_super) {
13621
13681
  * Set the relative sizes for the widgets in the panel.
13622
13682
  *
13623
13683
  * @param sizes - The relative sizes for the widgets in the panel.
13684
+ * @param update - Update the layout after setting relative sizes.
13685
+ * Default is True.
13624
13686
  *
13625
13687
  * #### Notes
13626
13688
  * Extra values are ignored, too few will yield an undefined layout.
13627
13689
  *
13628
13690
  * The actual geometry of the DOM nodes is updated asynchronously.
13629
13691
  */
13630
- SplitPanel.prototype.setRelativeSizes = function (sizes) {
13631
- this.layout.setRelativeSizes(sizes);
13692
+ SplitPanel.prototype.setRelativeSizes = function (sizes, update) {
13693
+ if (update === void 0) { update = true; }
13694
+ this.layout.setRelativeSizes(sizes, update);
13632
13695
  };
13633
13696
  /**
13634
13697
  * Handle the DOM events for the split panel.
@@ -13805,6 +13868,8 @@ var SplitPanel$1 = /** @class */ (function (_super) {
13805
13868
  // Clear the override cursor.
13806
13869
  this._pressData.override.dispose();
13807
13870
  this._pressData = null;
13871
+ // Emit the handle moved signal.
13872
+ this._handleMoved.emit();
13808
13873
  // Remove the extra document listeners.
13809
13874
  document.removeEventListener('mouseup', this, true);
13810
13875
  document.removeEventListener('mousemove', this, true);
@@ -13905,6 +13970,7 @@ var AccordionPanel = /** @class */ (function (_super) {
13905
13970
  function AccordionPanel(options) {
13906
13971
  if (options === void 0) { options = {}; }
13907
13972
  var _this = _super.call(this, __assign$1(__assign$1({}, options), { layout: Private$d.createLayout(options) })) || this;
13973
+ _this._widgetSizesCache = new WeakMap();
13908
13974
  _this.addClass('lm-AccordionPanel');
13909
13975
  return _this;
13910
13976
  }
@@ -13956,6 +14022,34 @@ var AccordionPanel = /** @class */ (function (_super) {
13956
14022
  _super.prototype.addWidget.call(this, widget);
13957
14023
  widget.title.changed.connect(this._onTitleChanged, this);
13958
14024
  };
14025
+ /**
14026
+ * Collapse the widget at position `index`.
14027
+ *
14028
+ * #### Notes
14029
+ * If no widget is found for `index`, this will bail.
14030
+ *
14031
+ * @param index Widget index
14032
+ */
14033
+ AccordionPanel.prototype.collapse = function (index) {
14034
+ var widget = this.layout.widgets[index];
14035
+ if (widget && !widget.isHidden) {
14036
+ this._toggleExpansion(index);
14037
+ }
14038
+ };
14039
+ /**
14040
+ * Expand the widget at position `index`.
14041
+ *
14042
+ * #### Notes
14043
+ * If no widget is found for `index`, this will bail.
14044
+ *
14045
+ * @param index Widget index
14046
+ */
14047
+ AccordionPanel.prototype.expand = function (index) {
14048
+ var widget = this.layout.widgets[index];
14049
+ if (widget && widget.isHidden) {
14050
+ this._toggleExpansion(index);
14051
+ }
14052
+ };
13959
14053
  /**
13960
14054
  * Insert a widget at the specified index.
13961
14055
  *
@@ -14019,6 +14113,71 @@ var AccordionPanel = /** @class */ (function (_super) {
14019
14113
  this.update();
14020
14114
  }
14021
14115
  };
14116
+ /**
14117
+ * Compute the size of widgets in this panel on the title click event.
14118
+ * On closing, the size of the widget is cached and we will try to expand
14119
+ * the last opened widget.
14120
+ * On opening, we will use the cached size if it is available to restore the
14121
+ * widget.
14122
+ * In both cases, if we can not compute the size of widgets, we will let
14123
+ * `SplitLayout` decide.
14124
+ *
14125
+ * @param index - The index of widget to be opened of closed
14126
+ *
14127
+ * @returns Relative size of widgets in this panel, if this size can
14128
+ * not be computed, return `undefined`
14129
+ */
14130
+ AccordionPanel.prototype._computeWidgetSize = function (index) {
14131
+ var layout = this.layout;
14132
+ var widget = layout.widgets[index];
14133
+ if (!widget) {
14134
+ return undefined;
14135
+ }
14136
+ var isHidden = widget.isHidden;
14137
+ var widgetSizes = layout.absoluteSizes();
14138
+ var delta = (isHidden ? -1 : 1) * this.spacing;
14139
+ var totalSize = widgetSizes.reduce(function (prev, curr) { return prev + curr; });
14140
+ var newSize = __spreadArrays(widgetSizes);
14141
+ if (!isHidden) {
14142
+ // Hide the widget
14143
+ var currentSize = widgetSizes[index];
14144
+ this._widgetSizesCache.set(widget, currentSize);
14145
+ newSize[index] = 0;
14146
+ var widgetToCollapse = newSize.map(function (sz) { return sz > 0; }).lastIndexOf(true);
14147
+ if (widgetToCollapse === -1) {
14148
+ // All widget are closed, let the `SplitLayout` compute widget sizes.
14149
+ return undefined;
14150
+ }
14151
+ newSize[widgetToCollapse] =
14152
+ widgetSizes[widgetToCollapse] + currentSize + delta;
14153
+ }
14154
+ else {
14155
+ // Show the widget
14156
+ var previousSize_1 = this._widgetSizesCache.get(widget);
14157
+ if (!previousSize_1) {
14158
+ // Previous size is unavailable, let the `SplitLayout` compute widget sizes.
14159
+ return undefined;
14160
+ }
14161
+ newSize[index] += previousSize_1;
14162
+ var widgetToCollapse = newSize
14163
+ .map(function (sz) { return sz - previousSize_1 > 0; })
14164
+ .lastIndexOf(true);
14165
+ if (widgetToCollapse === -1) {
14166
+ // Can not reduce the size of one widget, reduce all opened widgets
14167
+ // proportionally with its size.
14168
+ newSize.forEach(function (_, idx) {
14169
+ if (idx !== index) {
14170
+ newSize[idx] -=
14171
+ (widgetSizes[idx] / totalSize) * (previousSize_1 - delta);
14172
+ }
14173
+ });
14174
+ }
14175
+ else {
14176
+ newSize[widgetToCollapse] -= previousSize_1 - delta;
14177
+ }
14178
+ }
14179
+ return newSize.map(function (sz) { return sz / (totalSize + delta); });
14180
+ };
14022
14181
  /**
14023
14182
  * Handle the `'click'` event for the accordion panel
14024
14183
  */
@@ -14031,18 +14190,7 @@ var AccordionPanel = /** @class */ (function (_super) {
14031
14190
  if (index >= 0) {
14032
14191
  event.preventDefault();
14033
14192
  event.stopPropagation();
14034
- var title = this.titles[index];
14035
- var widget = this.layout.widgets[index];
14036
- if (widget.isHidden) {
14037
- title.classList.add('lm-mod-expanded');
14038
- title.setAttribute('aria-expanded', 'true');
14039
- widget.show();
14040
- }
14041
- else {
14042
- title.classList.remove('lm-mod-expanded');
14043
- title.setAttribute('aria-expanded', 'false');
14044
- widget.hide();
14045
- }
14193
+ this._toggleExpansion(index);
14046
14194
  }
14047
14195
  }
14048
14196
  };
@@ -14094,6 +14242,24 @@ var AccordionPanel = /** @class */ (function (_super) {
14094
14242
  }
14095
14243
  }
14096
14244
  };
14245
+ AccordionPanel.prototype._toggleExpansion = function (index) {
14246
+ var title = this.titles[index];
14247
+ var widget = this.layout.widgets[index];
14248
+ var newSize = this._computeWidgetSize(index);
14249
+ if (newSize) {
14250
+ this.setRelativeSizes(newSize, false);
14251
+ }
14252
+ if (widget.isHidden) {
14253
+ title.classList.add('lm-mod-expanded');
14254
+ title.setAttribute('aria-expanded', 'true');
14255
+ widget.show();
14256
+ }
14257
+ else {
14258
+ title.classList.remove('lm-mod-expanded');
14259
+ title.setAttribute('aria-expanded', 'false');
14260
+ widget.hide();
14261
+ }
14262
+ };
14097
14263
  return AccordionPanel;
14098
14264
  }(SplitPanel$1));
14099
14265
  /**
@@ -19573,7 +19739,10 @@ var DockLayout = /** @class */ (function (_super) {
19573
19739
  // Create the root node for the new config.
19574
19740
  if (mainConfig) {
19575
19741
  this._root = Private$6.realizeAreaConfig(mainConfig, {
19576
- createTabBar: function () { return _this._createTabBar(); },
19742
+ // Ignoring optional `document` argument as we must reuse `this._document`
19743
+ createTabBar: function (document) {
19744
+ return _this._createTabBar();
19745
+ },
19577
19746
  createHandle: function () { return _this._createHandle(); }
19578
19747
  }, this._document);
19579
19748
  }
@@ -25689,7 +25858,7 @@ styleInject$1(css_248z$1$1);
25689
25858
  var css_248z$9 = ".lm-TabPanel-tabBar,.p-TabPanel-tabBar{z-index:1}.lm-TabPanel-stackedPanel,.p-TabPanel-stackedPanel{z-index:0}";
25690
25859
  styleInject$1(css_248z$9);
25691
25860
 
25692
- /*! *****************************************************************************
25861
+ /******************************************************************************
25693
25862
  Copyright (c) Microsoft Corporation.
25694
25863
 
25695
25864
  Permission to use, copy, modify, and/or distribute this software for any