@hpcc-js/phosphor 2.16.7 → 2.16.9

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.7";
5
- var BUILD_VERSION = "2.104.14";
4
+ var PKG_VERSION = "2.16.9";
5
+ var BUILD_VERSION = "2.104.20";
6
6
 
7
7
  // Copyright (c) Jupyter Development Team.
8
8
  // Distributed under the terms of the Modified BSD License.
@@ -3078,6 +3078,8 @@ var Signal = /** @class */ (function () {
3078
3078
  * ### Notes
3079
3079
  * The callback function must be synchronous.
3080
3080
  *
3081
+ * @deprecated This feature will be removed in Lumino 2.
3082
+ *
3081
3083
  * @param fn The callback during which the signal is blocked
3082
3084
  */
3083
3085
  Signal.prototype.block = function (fn) {
@@ -3143,6 +3145,8 @@ var Signal = /** @class */ (function () {
3143
3145
  * ### Notes
3144
3146
  * The callback function must be synchronous.
3145
3147
  *
3148
+ * @deprecated This feature will be removed in Lumino 2.
3149
+ *
3146
3150
  * @param sender The signals sender
3147
3151
  * @param fn The callback during which all signals are blocked
3148
3152
  */
@@ -10821,30 +10825,20 @@ var Widget = /** @class */ (function () {
10821
10825
  if (this._hiddenMode === value) {
10822
10826
  return;
10823
10827
  }
10824
- this._hiddenMode = value;
10825
- switch (value) {
10826
- case Widget.HiddenMode.Display:
10827
- this.node.style.willChange = 'auto';
10828
- break;
10829
- case Widget.HiddenMode.Scale:
10830
- this.node.style.willChange = 'transform';
10831
- break;
10828
+ if (this.isHidden) {
10829
+ // Reset styles set by previous mode.
10830
+ this._toggleHidden(false);
10832
10831
  }
10832
+ if (value == Widget.HiddenMode.Scale) {
10833
+ this.node.style.willChange = 'transform';
10834
+ }
10835
+ else {
10836
+ this.node.style.willChange = 'auto';
10837
+ }
10838
+ this._hiddenMode = value;
10833
10839
  if (this.isHidden) {
10834
- if (value === Widget.HiddenMode.Display) {
10835
- this.addClass('lm-mod-hidden');
10836
- /* <DEPRECATED> */
10837
- this.addClass('p-mod-hidden');
10838
- /* </DEPRECATED> */
10839
- this.node.style.transform = '';
10840
- }
10841
- else {
10842
- this.node.style.transform = 'scale(0)';
10843
- this.removeClass('lm-mod-hidden');
10844
- /* <DEPRECATED> */
10845
- this.removeClass('p-mod-hidden');
10846
- /* </DEPRECATED> */
10847
- }
10840
+ // Set styles for new mode.
10841
+ this._toggleHidden(true);
10848
10842
  }
10849
10843
  },
10850
10844
  enumerable: true,
@@ -11068,15 +11062,7 @@ var Widget = /** @class */ (function () {
11068
11062
  }
11069
11063
  this.clearFlag(Widget.Flag.IsHidden);
11070
11064
  this.node.removeAttribute('aria-hidden');
11071
- if (this.hiddenMode === Widget.HiddenMode.Display) {
11072
- this.removeClass('lm-mod-hidden');
11073
- /* <DEPRECATED> */
11074
- this.removeClass('p-mod-hidden');
11075
- /* </DEPRECATED> */
11076
- }
11077
- else {
11078
- this.node.style.transform = '';
11079
- }
11065
+ this._toggleHidden(false);
11080
11066
  if (this.isAttached && (!this.parent || this.parent.isVisible)) {
11081
11067
  MessageLoop.sendMessage(this, Widget.Msg.AfterShow);
11082
11068
  }
@@ -11102,15 +11088,7 @@ var Widget = /** @class */ (function () {
11102
11088
  }
11103
11089
  this.setFlag(Widget.Flag.IsHidden);
11104
11090
  this.node.setAttribute('aria-hidden', 'true');
11105
- if (this.hiddenMode === Widget.HiddenMode.Display) {
11106
- this.addClass('lm-mod-hidden');
11107
- /* <DEPRECATED> */
11108
- this.addClass('p-mod-hidden');
11109
- /* </DEPRECATED> */
11110
- }
11111
- else {
11112
- this.node.style.transform = 'scale(0)';
11113
- }
11091
+ this._toggleHidden(true);
11114
11092
  if (this.isAttached && (!this.parent || this.parent.isVisible)) {
11115
11093
  MessageLoop.sendMessage(this, Widget.Msg.AfterHide);
11116
11094
  }
@@ -11372,6 +11350,42 @@ var Widget = /** @class */ (function () {
11372
11350
  * The default implementation of this handler is a no-op.
11373
11351
  */
11374
11352
  Widget.prototype.onChildRemoved = function (msg) { };
11353
+ Widget.prototype._toggleHidden = function (hidden) {
11354
+ if (hidden) {
11355
+ switch (this._hiddenMode) {
11356
+ case Widget.HiddenMode.Display:
11357
+ this.addClass('lm-mod-hidden');
11358
+ /* <DEPRECATED> */
11359
+ this.addClass('p-mod-hidden');
11360
+ /* </DEPRECATED> */
11361
+ break;
11362
+ case Widget.HiddenMode.Scale:
11363
+ this.node.style.transform = 'scale(0)';
11364
+ break;
11365
+ case Widget.HiddenMode.ContentVisibility:
11366
+ this.node.style.contentVisibility = 'hidden';
11367
+ this.node.style.zIndex = '-1';
11368
+ break;
11369
+ }
11370
+ }
11371
+ else {
11372
+ switch (this._hiddenMode) {
11373
+ case Widget.HiddenMode.Display:
11374
+ this.removeClass('lm-mod-hidden');
11375
+ /* <DEPRECATED> */
11376
+ this.removeClass('p-mod-hidden');
11377
+ /* </DEPRECATED> */
11378
+ break;
11379
+ case Widget.HiddenMode.Scale:
11380
+ this.node.style.transform = '';
11381
+ break;
11382
+ case Widget.HiddenMode.ContentVisibility:
11383
+ this.node.style.contentVisibility = '';
11384
+ this.node.style.zIndex = '';
11385
+ break;
11386
+ }
11387
+ }
11388
+ };
11375
11389
  return Widget;
11376
11390
  }());
11377
11391
  /**
@@ -11388,6 +11402,10 @@ var Widget = /** @class */ (function () {
11388
11402
  * Hide the widget by setting the `transform` to `'scale(0)'`.
11389
11403
  */
11390
11404
  HiddenMode[HiddenMode["Scale"] = 1] = "Scale";
11405
+ /**
11406
+ *Hide the widget by setting the `content-visibility` to `'hidden'`.
11407
+ */
11408
+ HiddenMode[HiddenMode["ContentVisibility"] = 2] = "ContentVisibility";
11391
11409
  })(Widget.HiddenMode || (Widget.HiddenMode = {}));
11392
11410
  (function (Flag) {
11393
11411
  /**
@@ -20306,16 +20324,24 @@ var DockLayout = /** @class */ (function (_super) {
20306
20324
  }
20307
20325
  // Using transform create an additional layer in the pixel pipeline
20308
20326
  // to limit the number of layer, it is set only if there is more than one widget.
20309
- if (this._hiddenMode === Widget.HiddenMode.Scale &&
20310
- refNode.tabBar.titles.length > 0) {
20311
- if (refNode.tabBar.titles.length == 1) {
20327
+ if (this._hiddenMode === Widget.HiddenMode.Scale) {
20328
+ if (refNode.tabBar.titles.length === 0) {
20329
+ // Singular tab should use display mode to limit number of layers.
20330
+ widget.hiddenMode = Widget.HiddenMode.Display;
20331
+ }
20332
+ else if (refNode.tabBar.titles.length == 1) {
20333
+ // If we are adding a second tab, switch the existing tab back to scale.
20312
20334
  var existingWidget = refNode.tabBar.titles[0].owner;
20313
20335
  existingWidget.hiddenMode = Widget.HiddenMode.Scale;
20314
20336
  }
20315
- widget.hiddenMode = Widget.HiddenMode.Scale;
20337
+ else {
20338
+ // For the third and subsequent tabs no special action is needed.
20339
+ widget.hiddenMode = Widget.HiddenMode.Scale;
20340
+ }
20316
20341
  }
20317
20342
  else {
20318
- widget.hiddenMode = Widget.HiddenMode.Display;
20343
+ // For all other modes just propagate the current mode.
20344
+ widget.hiddenMode = this._hiddenMode;
20319
20345
  }
20320
20346
  // Insert the widget's tab relative to the target index.
20321
20347
  refNode.tabBar.insertTab(index + (after ? 1 : 0), widget.title);
@@ -21748,6 +21774,8 @@ var DockPanel$1 = /** @class */ (function (_super) {
21748
21774
  DockPanel.prototype._evtDragLeave = function (event) {
21749
21775
  // Mark the event as handled.
21750
21776
  event.preventDefault();
21777
+ if (this._tabsConstrained && event.source !== this)
21778
+ return;
21751
21779
  event.stopPropagation();
21752
21780
  // The new target might be a descendant, so we might still handle the drop.
21753
21781
  // Hide asynchronously so that if a lm-dragover event bubbles up to us, the
@@ -21760,7 +21788,6 @@ var DockPanel$1 = /** @class */ (function (_super) {
21760
21788
  DockPanel.prototype._evtDragOver = function (event) {
21761
21789
  // Mark the event as handled.
21762
21790
  event.preventDefault();
21763
- event.stopPropagation();
21764
21791
  // Show the drop indicator overlay and update the drop
21765
21792
  // action based on the drop target zone under the mouse.
21766
21793
  if ((this._tabsConstrained && event.source !== this) ||
@@ -21768,6 +21795,7 @@ var DockPanel$1 = /** @class */ (function (_super) {
21768
21795
  event.dropAction = 'none';
21769
21796
  }
21770
21797
  else {
21798
+ event.stopPropagation();
21771
21799
  event.dropAction = event.proposedAction;
21772
21800
  }
21773
21801
  };
@@ -21777,7 +21805,6 @@ var DockPanel$1 = /** @class */ (function (_super) {
21777
21805
  DockPanel.prototype._evtDrop = function (event) {
21778
21806
  // Mark the event as handled.
21779
21807
  event.preventDefault();
21780
- event.stopPropagation();
21781
21808
  // Hide the drop indicator overlay.
21782
21809
  this.overlay.hide(0);
21783
21810
  // Bail if the proposed action is to do nothing.
@@ -21789,7 +21816,8 @@ var DockPanel$1 = /** @class */ (function (_super) {
21789
21816
  var clientX = event.clientX, clientY = event.clientY;
21790
21817
  var _a = Private$5.findDropTarget(this, clientX, clientY, this._edges), zone = _a.zone, target = _a.target;
21791
21818
  // Bail if the drop zone is invalid.
21792
- if (zone === 'invalid') {
21819
+ if ((this._tabsConstrained && event.source !== this) ||
21820
+ zone === 'invalid') {
21793
21821
  event.dropAction = 'none';
21794
21822
  return;
21795
21823
  }
@@ -21853,6 +21881,8 @@ var DockPanel$1 = /** @class */ (function (_super) {
21853
21881
  }
21854
21882
  // Accept the proposed drop action.
21855
21883
  event.dropAction = event.proposedAction;
21884
+ // Stop propagation if we have not bailed so far.
21885
+ event.stopPropagation();
21856
21886
  // Activate the dropped widget.
21857
21887
  this.activateWidget(widget);
21858
21888
  };
@@ -23518,7 +23548,10 @@ var MenuBar = /** @class */ (function (_super) {
23518
23548
  function MenuBar(options) {
23519
23549
  if (options === void 0) { options = {}; }
23520
23550
  var _this = _super.call(this, { node: Private$3.createNode() }) || this;
23551
+ // Track the index of the item that is currently focused. -1 means nothing focused.
23521
23552
  _this._activeIndex = -1;
23553
+ // Track which item can be focused using the TAB key. Unlike _activeIndex will always point to a menuitem.
23554
+ _this._tabFocusIndex = 0;
23522
23555
  _this._menus = [];
23523
23556
  _this._childMenu = null;
23524
23557
  _this.addClass('lm-MenuBar');
@@ -23615,6 +23648,10 @@ var MenuBar = /** @class */ (function (_super) {
23615
23648
  }
23616
23649
  // Update the active index.
23617
23650
  this._activeIndex = value;
23651
+ // Update the focus index.
23652
+ if (value !== -1) {
23653
+ this._tabFocusIndex = value;
23654
+ }
23618
23655
  // Update focus to new active index
23619
23656
  if (this._activeIndex >= 0 &&
23620
23657
  this.contentNode.childNodes[this._activeIndex]) {
@@ -23839,7 +23876,7 @@ var MenuBar = /** @class */ (function (_super) {
23839
23876
  */
23840
23877
  MenuBar.prototype.onActivateRequest = function (msg) {
23841
23878
  if (this.isAttached) {
23842
- this.node.focus();
23879
+ this.activeIndex = 0;
23843
23880
  }
23844
23881
  };
23845
23882
  /**
@@ -23850,6 +23887,9 @@ var MenuBar = /** @class */ (function (_super) {
23850
23887
  var menus = this._menus;
23851
23888
  var renderer = this.renderer;
23852
23889
  var activeIndex = this._activeIndex;
23890
+ var tabFocusIndex = this._tabFocusIndex >= 0 && this._tabFocusIndex < menus.length
23891
+ ? this._tabFocusIndex
23892
+ : 0;
23853
23893
  var content = new Array(menus.length);
23854
23894
  var _loop_1 = function (i, n) {
23855
23895
  var title = menus[i].title;
@@ -23860,6 +23900,7 @@ var MenuBar = /** @class */ (function (_super) {
23860
23900
  content[i] = renderer.renderItem({
23861
23901
  title: title,
23862
23902
  active: active,
23903
+ tabbable: i === tabFocusIndex,
23863
23904
  onfocus: function () {
23864
23905
  _this.activeIndex = i;
23865
23906
  }
@@ -23879,15 +23920,16 @@ var MenuBar = /** @class */ (function (_super) {
23879
23920
  MenuBar.prototype._evtKeyDown = function (event) {
23880
23921
  // Fetch the key code for the event.
23881
23922
  var kc = event.keyCode;
23882
- // Do not trap the tab key.
23923
+ // Reset the active index on tab, but do not trap the tab key.
23883
23924
  if (kc === 9) {
23925
+ this.activeIndex = -1;
23884
23926
  return;
23885
23927
  }
23886
23928
  // A menu bar handles all other keydown events.
23887
23929
  event.preventDefault();
23888
23930
  event.stopPropagation();
23889
- // Enter, Up Arrow, Down Arrow
23890
- if (kc === 13 || kc === 38 || kc === 40) {
23931
+ // Enter, Space, Up Arrow, Down Arrow
23932
+ if (kc === 13 || kc === 32 || kc === 38 || kc === 40) {
23891
23933
  this.openActiveMenu();
23892
23934
  return;
23893
23935
  }
@@ -24179,7 +24221,8 @@ var MenuBar = /** @class */ (function (_super) {
24179
24221
  var className = this.createItemClass(data);
24180
24222
  var dataset = this.createItemDataset(data);
24181
24223
  var aria = this.createItemARIA(data);
24182
- return h.li(__assign$2({ className: className, dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data));
24224
+ return h.li(__assign$2({ className: className,
24225
+ dataset: dataset, tabindex: data.tabbable ? '0' : '-1', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data));
24183
24226
  };
24184
24227
  /**
24185
24228
  * Render the icon element for a menu bar item.
@@ -24325,8 +24368,6 @@ var Private$3;
24325
24368
  /* </DEPRECATED> */
24326
24369
  node.appendChild(content);
24327
24370
  content.setAttribute('role', 'menubar');
24328
- node.tabIndex = 0;
24329
- content.tabIndex = 0;
24330
24371
  return node;
24331
24372
  }
24332
24373
  Private.createNode = createNode;