@hpcc-js/phosphor 2.16.6 → 2.16.7

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.6";
5
- var BUILD_VERSION = "2.104.13";
4
+ var PKG_VERSION = "2.16.7";
5
+ var BUILD_VERSION = "2.104.14";
6
6
 
7
7
  // Copyright (c) Jupyter Development Team.
8
8
  // Distributed under the terms of the Modified BSD License.
@@ -2823,6 +2823,195 @@ var UUID;
2823
2823
  UUID.uuid4 = uuid4Factory(Random.getRandomValues);
2824
2824
  })(UUID || (UUID = {}));
2825
2825
 
2826
+ // Copyright (c) Jupyter Development Team.
2827
+ // Distributed under the terms of the Modified BSD License.
2828
+ /*-----------------------------------------------------------------------------
2829
+ | Copyright (c) 2014-2017, PhosphorJS Contributors
2830
+ |
2831
+ | Distributed under the terms of the BSD 3-Clause License.
2832
+ |
2833
+ | The full license is in the file LICENSE, distributed with this software.
2834
+ |----------------------------------------------------------------------------*/
2835
+ /**
2836
+ * A class which attaches a value to an external object.
2837
+ *
2838
+ * #### Notes
2839
+ * Attached properties are used to extend the state of an object with
2840
+ * semantic data from an unrelated class. They also encapsulate value
2841
+ * creation, coercion, and notification.
2842
+ *
2843
+ * Because attached property values are stored in a hash table, which
2844
+ * in turn is stored in a WeakMap keyed on the owner object, there is
2845
+ * non-trivial storage overhead involved in their use. The pattern is
2846
+ * therefore best used for the storage of rare data.
2847
+ */
2848
+ var AttachedProperty = /** @class */ (function () {
2849
+ /**
2850
+ * Construct a new attached property.
2851
+ *
2852
+ * @param options - The options for initializing the property.
2853
+ */
2854
+ function AttachedProperty(options) {
2855
+ this._pid = Private$r.nextPID();
2856
+ this.name = options.name;
2857
+ this._create = options.create;
2858
+ this._coerce = options.coerce || null;
2859
+ this._compare = options.compare || null;
2860
+ this._changed = options.changed || null;
2861
+ }
2862
+ /**
2863
+ * Get the current value of the property for a given owner.
2864
+ *
2865
+ * @param owner - The property owner of interest.
2866
+ *
2867
+ * @returns The current value of the property.
2868
+ *
2869
+ * #### Notes
2870
+ * If the value has not yet been set, the default value will be
2871
+ * computed and assigned as the current value of the property.
2872
+ */
2873
+ AttachedProperty.prototype.get = function (owner) {
2874
+ var value;
2875
+ var map = Private$r.ensureMap(owner);
2876
+ if (this._pid in map) {
2877
+ value = map[this._pid];
2878
+ }
2879
+ else {
2880
+ value = map[this._pid] = this._createValue(owner);
2881
+ }
2882
+ return value;
2883
+ };
2884
+ /**
2885
+ * Set the current value of the property for a given owner.
2886
+ *
2887
+ * @param owner - The property owner of interest.
2888
+ *
2889
+ * @param value - The value for the property.
2890
+ *
2891
+ * #### Notes
2892
+ * If the value has not yet been set, the default value will be
2893
+ * computed and used as the previous value for the comparison.
2894
+ */
2895
+ AttachedProperty.prototype.set = function (owner, value) {
2896
+ var oldValue;
2897
+ var map = Private$r.ensureMap(owner);
2898
+ if (this._pid in map) {
2899
+ oldValue = map[this._pid];
2900
+ }
2901
+ else {
2902
+ oldValue = map[this._pid] = this._createValue(owner);
2903
+ }
2904
+ var newValue = this._coerceValue(owner, value);
2905
+ this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
2906
+ };
2907
+ /**
2908
+ * Explicitly coerce the current property value for a given owner.
2909
+ *
2910
+ * @param owner - The property owner of interest.
2911
+ *
2912
+ * #### Notes
2913
+ * If the value has not yet been set, the default value will be
2914
+ * computed and used as the previous value for the comparison.
2915
+ */
2916
+ AttachedProperty.prototype.coerce = function (owner) {
2917
+ var oldValue;
2918
+ var map = Private$r.ensureMap(owner);
2919
+ if (this._pid in map) {
2920
+ oldValue = map[this._pid];
2921
+ }
2922
+ else {
2923
+ oldValue = map[this._pid] = this._createValue(owner);
2924
+ }
2925
+ var newValue = this._coerceValue(owner, oldValue);
2926
+ this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
2927
+ };
2928
+ /**
2929
+ * Get or create the default value for the given owner.
2930
+ */
2931
+ AttachedProperty.prototype._createValue = function (owner) {
2932
+ var create = this._create;
2933
+ return create(owner);
2934
+ };
2935
+ /**
2936
+ * Coerce the value for the given owner.
2937
+ */
2938
+ AttachedProperty.prototype._coerceValue = function (owner, value) {
2939
+ var coerce = this._coerce;
2940
+ return coerce ? coerce(owner, value) : value;
2941
+ };
2942
+ /**
2943
+ * Compare the old value and new value for equality.
2944
+ */
2945
+ AttachedProperty.prototype._compareValue = function (oldValue, newValue) {
2946
+ var compare = this._compare;
2947
+ return compare ? compare(oldValue, newValue) : oldValue === newValue;
2948
+ };
2949
+ /**
2950
+ * Run the change notification if the given values are different.
2951
+ */
2952
+ AttachedProperty.prototype._maybeNotify = function (owner, oldValue, newValue) {
2953
+ var changed = this._changed;
2954
+ if (changed && !this._compareValue(oldValue, newValue)) {
2955
+ changed(owner, oldValue, newValue);
2956
+ }
2957
+ };
2958
+ return AttachedProperty;
2959
+ }());
2960
+ /**
2961
+ * The namespace for the `AttachedProperty` class statics.
2962
+ */
2963
+ (function (AttachedProperty) {
2964
+ /**
2965
+ * Clear the stored property data for the given owner.
2966
+ *
2967
+ * @param owner - The property owner of interest.
2968
+ *
2969
+ * #### Notes
2970
+ * This will clear all property values for the owner, but it will
2971
+ * **not** run the change notification for any of the properties.
2972
+ */
2973
+ function clearData(owner) {
2974
+ Private$r.ownerData.delete(owner);
2975
+ }
2976
+ AttachedProperty.clearData = clearData;
2977
+ })(AttachedProperty || (AttachedProperty = {}));
2978
+ /**
2979
+ * The namespace for the module implementation details.
2980
+ */
2981
+ var Private$r;
2982
+ (function (Private) {
2983
+ /**
2984
+ * A weak mapping of property owner to property map.
2985
+ */
2986
+ Private.ownerData = new WeakMap();
2987
+ /**
2988
+ * A function which computes successive unique property ids.
2989
+ */
2990
+ Private.nextPID = (function () {
2991
+ var id = 0;
2992
+ return function () {
2993
+ var rand = Math.random();
2994
+ var stem = ("" + rand).slice(2);
2995
+ return "pid-" + stem + "-" + id++;
2996
+ };
2997
+ })();
2998
+ /**
2999
+ * Lookup the data map for the property owner.
3000
+ *
3001
+ * This will create the map if one does not already exist.
3002
+ */
3003
+ function ensureMap(owner) {
3004
+ var map = Private.ownerData.get(owner);
3005
+ if (map) {
3006
+ return map;
3007
+ }
3008
+ map = Object.create(null);
3009
+ Private.ownerData.set(owner, map);
3010
+ return map;
3011
+ }
3012
+ Private.ensureMap = ensureMap;
3013
+ })(Private$r || (Private$r = {}));
3014
+
2826
3015
  // Copyright (c) Jupyter Development Team.
2827
3016
  /**
2828
3017
  * A concrete implementation of `ISignal`.
@@ -2880,8 +3069,26 @@ var Signal = /** @class */ (function () {
2880
3069
  * @param sender - The sender which owns the signal.
2881
3070
  */
2882
3071
  function Signal(sender) {
3072
+ this._blockedCount = 0;
2883
3073
  this.sender = sender;
2884
3074
  }
3075
+ /**
3076
+ * Block the signal during the execution of a callback.
3077
+ *
3078
+ * ### Notes
3079
+ * The callback function must be synchronous.
3080
+ *
3081
+ * @param fn The callback during which the signal is blocked
3082
+ */
3083
+ Signal.prototype.block = function (fn) {
3084
+ this._blockedCount++;
3085
+ try {
3086
+ fn();
3087
+ }
3088
+ finally {
3089
+ this._blockedCount--;
3090
+ }
3091
+ };
2885
3092
  /**
2886
3093
  * Connect a slot to the signal.
2887
3094
  *
@@ -2893,7 +3100,7 @@ var Signal = /** @class */ (function () {
2893
3100
  * @returns `true` if the connection succeeds, `false` otherwise.
2894
3101
  */
2895
3102
  Signal.prototype.connect = function (slot, thisArg) {
2896
- return Private$r.connect(this, slot, thisArg);
3103
+ return Private$q.connect(this, slot, thisArg);
2897
3104
  };
2898
3105
  /**
2899
3106
  * Disconnect a slot from the signal.
@@ -2906,7 +3113,7 @@ var Signal = /** @class */ (function () {
2906
3113
  * @returns `true` if the connection is removed, `false` otherwise.
2907
3114
  */
2908
3115
  Signal.prototype.disconnect = function (slot, thisArg) {
2909
- return Private$r.disconnect(this, slot, thisArg);
3116
+ return Private$q.disconnect(this, slot, thisArg);
2910
3117
  };
2911
3118
  /**
2912
3119
  * Emit the signal and invoke the connected slots.
@@ -2919,7 +3126,9 @@ var Signal = /** @class */ (function () {
2919
3126
  * Exceptions thrown by connected slots will be caught and logged.
2920
3127
  */
2921
3128
  Signal.prototype.emit = function (args) {
2922
- Private$r.emit(this, args);
3129
+ if (!this._blockedCount) {
3130
+ Private$q.emit(this, args);
3131
+ }
2923
3132
  };
2924
3133
  return Signal;
2925
3134
  }());
@@ -2927,6 +3136,27 @@ var Signal = /** @class */ (function () {
2927
3136
  * The namespace for the `Signal` class statics.
2928
3137
  */
2929
3138
  (function (Signal) {
3139
+ /**
3140
+ * Block all signals emitted by an object during
3141
+ * the execution of a callback.
3142
+ *
3143
+ * ### Notes
3144
+ * The callback function must be synchronous.
3145
+ *
3146
+ * @param sender The signals sender
3147
+ * @param fn The callback during which all signals are blocked
3148
+ */
3149
+ function blockAll(sender, fn) {
3150
+ var blockedProperty = Private$q.blockedProperty;
3151
+ blockedProperty.set(sender, blockedProperty.get(sender) + 1);
3152
+ try {
3153
+ fn();
3154
+ }
3155
+ finally {
3156
+ blockedProperty.set(sender, blockedProperty.get(sender) - 1);
3157
+ }
3158
+ }
3159
+ Signal.blockAll = blockAll;
2930
3160
  /**
2931
3161
  * Remove all connections between a sender and receiver.
2932
3162
  *
@@ -2940,7 +3170,7 @@ var Signal = /** @class */ (function () {
2940
3170
  * the receiver.
2941
3171
  */
2942
3172
  function disconnectBetween(sender, receiver) {
2943
- Private$r.disconnectBetween(sender, receiver);
3173
+ Private$q.disconnectBetween(sender, receiver);
2944
3174
  }
2945
3175
  Signal.disconnectBetween = disconnectBetween;
2946
3176
  /**
@@ -2949,7 +3179,7 @@ var Signal = /** @class */ (function () {
2949
3179
  * @param sender - The sender object of interest.
2950
3180
  */
2951
3181
  function disconnectSender(sender) {
2952
- Private$r.disconnectSender(sender);
3182
+ Private$q.disconnectSender(sender);
2953
3183
  }
2954
3184
  Signal.disconnectSender = disconnectSender;
2955
3185
  /**
@@ -2963,7 +3193,7 @@ var Signal = /** @class */ (function () {
2963
3193
  * the receiver.
2964
3194
  */
2965
3195
  function disconnectReceiver(receiver) {
2966
- Private$r.disconnectReceiver(receiver);
3196
+ Private$q.disconnectReceiver(receiver);
2967
3197
  }
2968
3198
  Signal.disconnectReceiver = disconnectReceiver;
2969
3199
  /**
@@ -2977,7 +3207,7 @@ var Signal = /** @class */ (function () {
2977
3207
  * the receiver.
2978
3208
  */
2979
3209
  function disconnectAll(object) {
2980
- Private$r.disconnectAll(object);
3210
+ Private$q.disconnectAll(object);
2981
3211
  }
2982
3212
  Signal.disconnectAll = disconnectAll;
2983
3213
  /**
@@ -2990,7 +3220,7 @@ var Signal = /** @class */ (function () {
2990
3220
  * associated with the object.
2991
3221
  */
2992
3222
  function clearData(object) {
2993
- Private$r.disconnectAll(object);
3223
+ Private$q.disconnectAll(object);
2994
3224
  }
2995
3225
  Signal.clearData = clearData;
2996
3226
  /**
@@ -3002,7 +3232,7 @@ var Signal = /** @class */ (function () {
3002
3232
  * The default exception handler is `console.error`.
3003
3233
  */
3004
3234
  function getExceptionHandler() {
3005
- return Private$r.exceptionHandler;
3235
+ return Private$q.exceptionHandler;
3006
3236
  }
3007
3237
  Signal.getExceptionHandler = getExceptionHandler;
3008
3238
  /**
@@ -3016,8 +3246,8 @@ var Signal = /** @class */ (function () {
3016
3246
  * The exception handler is invoked when a slot throws an exception.
3017
3247
  */
3018
3248
  function setExceptionHandler(handler) {
3019
- var old = Private$r.exceptionHandler;
3020
- Private$r.exceptionHandler = handler;
3249
+ var old = Private$q.exceptionHandler;
3250
+ Private$q.exceptionHandler = handler;
3021
3251
  return old;
3022
3252
  }
3023
3253
  Signal.setExceptionHandler = setExceptionHandler;
@@ -3025,7 +3255,7 @@ var Signal = /** @class */ (function () {
3025
3255
  /**
3026
3256
  * The namespace for the module implementation details.
3027
3257
  */
3028
- var Private$r;
3258
+ var Private$q;
3029
3259
  (function (Private) {
3030
3260
  /**
3031
3261
  * The signal exception handler function.
@@ -3226,6 +3456,9 @@ var Private$r;
3226
3456
  * Exceptions thrown by connected slots will be caught and logged.
3227
3457
  */
3228
3458
  function emit(signal, args) {
3459
+ if (Private.blockedProperty.get(signal.sender) > 0) {
3460
+ return;
3461
+ }
3229
3462
  // If there are no receivers, there is nothing to do.
3230
3463
  var receivers = receiversForSender.get(signal.sender);
3231
3464
  if (!receivers || receivers.length === 0) {
@@ -3329,7 +3562,14 @@ var Private$r;
3329
3562
  function isDeadConnection(connection) {
3330
3563
  return connection.signal === null;
3331
3564
  }
3332
- })(Private$r || (Private$r = {}));
3565
+ /**
3566
+ * A property indicating a sender has been blocked if its value is not 0.
3567
+ */
3568
+ Private.blockedProperty = new AttachedProperty({
3569
+ name: 'blocked',
3570
+ create: function () { return 0; }
3571
+ });
3572
+ })(Private$q || (Private$q = {}));
3333
3573
 
3334
3574
  /*! *****************************************************************************
3335
3575
  Copyright (c) Microsoft Corporation.
@@ -3834,11 +4074,11 @@ var Selector;
3834
4074
  * same selector are extremely fast.
3835
4075
  */
3836
4076
  function calculateSpecificity(selector) {
3837
- if (selector in Private$q.specificityCache) {
3838
- return Private$q.specificityCache[selector];
4077
+ if (selector in Private$p.specificityCache) {
4078
+ return Private$p.specificityCache[selector];
3839
4079
  }
3840
- var result = Private$q.calculateSingle(selector);
3841
- return (Private$q.specificityCache[selector] = result);
4080
+ var result = Private$p.calculateSingle(selector);
4081
+ return (Private$p.specificityCache[selector] = result);
3842
4082
  }
3843
4083
  Selector.calculateSpecificity = calculateSpecificity;
3844
4084
  /**
@@ -3853,17 +4093,17 @@ var Selector;
3853
4093
  * selector are extremely fast.
3854
4094
  */
3855
4095
  function isValid(selector) {
3856
- if (selector in Private$q.validityCache) {
3857
- return Private$q.validityCache[selector];
4096
+ if (selector in Private$p.validityCache) {
4097
+ return Private$p.validityCache[selector];
3858
4098
  }
3859
4099
  var result = true;
3860
4100
  try {
3861
- Private$q.testElem.querySelector(selector);
4101
+ Private$p.testElem.querySelector(selector);
3862
4102
  }
3863
4103
  catch (err) {
3864
4104
  result = false;
3865
4105
  }
3866
- return (Private$q.validityCache[selector] = result);
4106
+ return (Private$p.validityCache[selector] = result);
3867
4107
  }
3868
4108
  Selector.isValid = isValid;
3869
4109
  /**
@@ -3880,14 +4120,14 @@ var Selector;
3880
4120
  * falling back onto a document query otherwise.
3881
4121
  */
3882
4122
  function matches(element, selector) {
3883
- return Private$q.protoMatchFunc.call(element, selector);
4123
+ return Private$p.protoMatchFunc.call(element, selector);
3884
4124
  }
3885
4125
  Selector.matches = matches;
3886
4126
  })(Selector || (Selector = {}));
3887
4127
  /**
3888
4128
  * The namespace for the module implementation details.
3889
4129
  */
3890
- var Private$q;
4130
+ var Private$p;
3891
4131
  (function (Private) {
3892
4132
  /**
3893
4133
  * A cache of computed selector specificity values.
@@ -4025,7 +4265,7 @@ var Private$q;
4025
4265
  * A regex which matches the negation pseudo-class globally.
4026
4266
  */
4027
4267
  var NEGATION_RE = /:not\(([^\)]+)\)/g;
4028
- })(Private$q || (Private$q = {}));
4268
+ })(Private$p || (Private$p = {}));
4029
4269
 
4030
4270
  // Copyright (c) Jupyter Development Team.
4031
4271
  // Distributed under the terms of the Modified BSD License.
@@ -4045,7 +4285,7 @@ var Private$q;
4045
4285
  * The default keyboard layout is US-English.
4046
4286
  */
4047
4287
  function getKeyboardLayout() {
4048
- return Private$p.keyboardLayout;
4288
+ return Private$o.keyboardLayout;
4049
4289
  }
4050
4290
  /**
4051
4291
  * A concrete implementation of [[IKeyboardLayout]] based on keycodes.
@@ -4277,15 +4517,40 @@ var EN_US = new KeycodeLayout('en-us', {
4277
4517
  /**
4278
4518
  * The namespace for the module implementation details.
4279
4519
  */
4280
- var Private$p;
4520
+ var Private$o;
4281
4521
  (function (Private) {
4282
4522
  /**
4283
4523
  * The global keyboard layout instance.
4284
4524
  */
4285
4525
  Private.keyboardLayout = EN_US;
4286
- })(Private$p || (Private$p = {}));
4526
+ })(Private$o || (Private$o = {}));
4527
+
4528
+ /*! *****************************************************************************
4529
+ Copyright (c) Microsoft Corporation.
4530
+
4531
+ Permission to use, copy, modify, and/or distribute this software for any
4532
+ purpose with or without fee is hereby granted.
4533
+
4534
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
4535
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4536
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
4537
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4538
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
4539
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4540
+ PERFORMANCE OF THIS SOFTWARE.
4541
+ ***************************************************************************** */
4542
+
4543
+ var __assign$1 = function() {
4544
+ __assign$1 = Object.assign || function __assign(t) {
4545
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4546
+ s = arguments[i];
4547
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
4548
+ }
4549
+ return t;
4550
+ };
4551
+ return __assign$1.apply(this, arguments);
4552
+ };
4287
4553
 
4288
- // Copyright (c) Jupyter Development Team.
4289
4554
  /**
4290
4555
  * An object which manages a collection of commands.
4291
4556
  *
@@ -4391,7 +4656,7 @@ var CommandRegistry = /** @class */ (function () {
4391
4656
  throw new Error("Command '" + id + "' already registered.");
4392
4657
  }
4393
4658
  // Add the command to the registry.
4394
- this._commands[id] = Private$o.createCommand(options);
4659
+ this._commands[id] = Private$n.createCommand(options);
4395
4660
  // Emit the `commandChanged` signal.
4396
4661
  this._commandChanged.emit({ id: id, type: 'added' });
4397
4662
  // Return a disposable which will remove the command.
@@ -4423,6 +4688,17 @@ var CommandRegistry = /** @class */ (function () {
4423
4688
  }
4424
4689
  this._commandChanged.emit({ id: id, type: id ? 'changed' : 'many-changed' });
4425
4690
  };
4691
+ /**
4692
+ * Get the description for a specific command.
4693
+ *
4694
+ * @param id - The id of the command of interest.
4695
+ *
4696
+ * @returns The description for the command.
4697
+ */
4698
+ CommandRegistry.prototype.describedBy = function (id) {
4699
+ var cmd = this._commands[id];
4700
+ return cmd ? cmd.describedBy || { args: null } : { args: null };
4701
+ };
4426
4702
  /**
4427
4703
  * Get the display label for a specific command.
4428
4704
  *
@@ -4683,7 +4959,7 @@ var CommandRegistry = /** @class */ (function () {
4683
4959
  CommandRegistry.prototype.addKeyBinding = function (options) {
4684
4960
  var _this = this;
4685
4961
  // Create the binding for the given options.
4686
- var binding = Private$o.createKeyBinding(options);
4962
+ var binding = Private$n.createKeyBinding(options);
4687
4963
  // Add the key binding to the bindings array.
4688
4964
  this._keyBindings.push(binding);
4689
4965
  // Emit the `bindingChanged` signal.
@@ -4730,7 +5006,7 @@ var CommandRegistry = /** @class */ (function () {
4730
5006
  // Add the keystroke to the current key sequence.
4731
5007
  this._keystrokes.push(keystroke);
4732
5008
  // Find the exact and partial matches for the key sequence.
4733
- var _a = Private$o.matchKeyBinding(this._keyBindings, this._keystrokes, event), exact = _a.exact, partial = _a.partial;
5009
+ var _a = Private$n.matchKeyBinding(this._keyBindings, this._keystrokes, event), exact = _a.exact, partial = _a.partial;
4734
5010
  // If there is no exact match and no partial match, replay
4735
5011
  // any suppressed events and clear the pending state.
4736
5012
  if (!exact && !partial) {
@@ -4770,7 +5046,7 @@ var CommandRegistry = /** @class */ (function () {
4770
5046
  this._clearTimer();
4771
5047
  this._timerID = window.setTimeout(function () {
4772
5048
  _this._onPendingTimeout();
4773
- }, Private$o.CHORD_TIMEOUT);
5049
+ }, Private$n.CHORD_TIMEOUT);
4774
5050
  };
4775
5051
  /**
4776
5052
  * Clear the pending timeout.
@@ -4789,7 +5065,7 @@ var CommandRegistry = /** @class */ (function () {
4789
5065
  return;
4790
5066
  }
4791
5067
  this._replaying = true;
4792
- this._keydownEvents.forEach(Private$o.replayKeyEvent);
5068
+ this._keydownEvents.forEach(Private$n.replayKeyEvent);
4793
5069
  this._replaying = false;
4794
5070
  };
4795
5071
  /**
@@ -4947,26 +5223,37 @@ var CommandRegistry = /** @class */ (function () {
4947
5223
  }
4948
5224
  CommandRegistry.normalizeKeys = normalizeKeys;
4949
5225
  /**
4950
- * Format a keystroke for display on the local system.
5226
+ * Format keystrokes for display on the local system.
5227
+ *
5228
+ * If a list of keystrokes is provided, it will be displayed as
5229
+ * a comma-separated string
5230
+ *
5231
+ * @param keystroke The keystrokes to format
5232
+ * @returns The keystrokes representation
4951
5233
  */
4952
- function formatKeystroke(keystroke) {
4953
- var mods = [];
4954
- var separator = Platform.IS_MAC ? ' ' : '+';
4955
- var parts = parseKeystroke(keystroke);
4956
- if (parts.ctrl) {
4957
- mods.push('Ctrl');
4958
- }
4959
- if (parts.alt) {
4960
- mods.push('Alt');
4961
- }
4962
- if (parts.shift) {
4963
- mods.push('Shift');
4964
- }
4965
- if (Platform.IS_MAC && parts.cmd) {
4966
- mods.push('Cmd');
5234
+ function formatKeystroke(keystroke) {
5235
+ return typeof keystroke === 'string'
5236
+ ? formatSingleKey(keystroke)
5237
+ : keystroke.map(formatSingleKey).join(', ');
5238
+ function formatSingleKey(key) {
5239
+ var mods = [];
5240
+ var separator = Platform.IS_MAC ? ' ' : '+';
5241
+ var parts = parseKeystroke(key);
5242
+ if (parts.ctrl) {
5243
+ mods.push('Ctrl');
5244
+ }
5245
+ if (parts.alt) {
5246
+ mods.push('Alt');
5247
+ }
5248
+ if (parts.shift) {
5249
+ mods.push('Shift');
5250
+ }
5251
+ if (Platform.IS_MAC && parts.cmd) {
5252
+ mods.push('Cmd');
5253
+ }
5254
+ mods.push(parts.key);
5255
+ return mods.map(Private$n.formatKey).join(separator);
4967
5256
  }
4968
- mods.push(parts.key);
4969
- return mods.map(Private$o.formatKey).join(separator);
4970
5257
  }
4971
5258
  CommandRegistry.formatKeystroke = formatKeystroke;
4972
5259
  /**
@@ -5017,7 +5304,7 @@ var CommandRegistry = /** @class */ (function () {
5017
5304
  /**
5018
5305
  * The namespace for the module implementation details.
5019
5306
  */
5020
- var Private$o;
5307
+ var Private$n;
5021
5308
  (function (Private) {
5022
5309
  /**
5023
5310
  * The timeout in ms for triggering a key binding chord.
@@ -5044,6 +5331,7 @@ var Private$o;
5044
5331
  /* </DEPRECATED> */
5045
5332
  return {
5046
5333
  execute: options.execute,
5334
+ describedBy: __assign$1({ args: null }, options.describedBy),
5047
5335
  label: asFunc(options.label, emptyStringFunc),
5048
5336
  mnemonic: asFunc(options.mnemonic, negativeOneFunc),
5049
5337
  icon: icon,
@@ -5289,7 +5577,7 @@ var Private$o;
5289
5577
  clone.view = event.view || window;
5290
5578
  return clone;
5291
5579
  }
5292
- })(Private$o || (Private$o = {}));
5580
+ })(Private$n || (Private$n = {}));
5293
5581
 
5294
5582
  // Copyright (c) Jupyter Development Team.
5295
5583
  /**
@@ -6886,7 +7174,7 @@ var LinkedList = /** @class */ (function () {
6886
7174
  * Constant.
6887
7175
  */
6888
7176
  LinkedList.prototype.addFirst = function (value) {
6889
- var node = new Private$n.LinkedListNode(this, value);
7177
+ var node = new Private$m.LinkedListNode(this, value);
6890
7178
  if (!this._first) {
6891
7179
  this._first = node;
6892
7180
  this._last = node;
@@ -6910,7 +7198,7 @@ var LinkedList = /** @class */ (function () {
6910
7198
  * Constant.
6911
7199
  */
6912
7200
  LinkedList.prototype.addLast = function (value) {
6913
- var node = new Private$n.LinkedListNode(this, value);
7201
+ var node = new Private$m.LinkedListNode(this, value);
6914
7202
  if (!this._last) {
6915
7203
  this._first = node;
6916
7204
  this._last = node;
@@ -6943,10 +7231,10 @@ var LinkedList = /** @class */ (function () {
6943
7231
  if (!ref || ref === this._first) {
6944
7232
  return this.addFirst(value);
6945
7233
  }
6946
- if (!(ref instanceof Private$n.LinkedListNode) || ref.list !== this) {
7234
+ if (!(ref instanceof Private$m.LinkedListNode) || ref.list !== this) {
6947
7235
  throw new Error('Reference node is not owned by the list.');
6948
7236
  }
6949
- var node = new Private$n.LinkedListNode(this, value);
7237
+ var node = new Private$m.LinkedListNode(this, value);
6950
7238
  var _ref = ref;
6951
7239
  var prev = _ref.prev;
6952
7240
  node.next = _ref;
@@ -6976,10 +7264,10 @@ var LinkedList = /** @class */ (function () {
6976
7264
  if (!ref || ref === this._last) {
6977
7265
  return this.addLast(value);
6978
7266
  }
6979
- if (!(ref instanceof Private$n.LinkedListNode) || ref.list !== this) {
7267
+ if (!(ref instanceof Private$m.LinkedListNode) || ref.list !== this) {
6980
7268
  throw new Error('Reference node is not owned by the list.');
6981
7269
  }
6982
- var node = new Private$n.LinkedListNode(this, value);
7270
+ var node = new Private$m.LinkedListNode(this, value);
6983
7271
  var _ref = ref;
6984
7272
  var next = _ref.next;
6985
7273
  node.next = next;
@@ -7055,7 +7343,7 @@ var LinkedList = /** @class */ (function () {
7055
7343
  * The node must be owned by the list.
7056
7344
  */
7057
7345
  LinkedList.prototype.removeNode = function (node) {
7058
- if (!(node instanceof Private$n.LinkedListNode) || node.list !== this) {
7346
+ if (!(node instanceof Private$m.LinkedListNode) || node.list !== this) {
7059
7347
  throw new Error('Node is not owned by the list.');
7060
7348
  }
7061
7349
  var _node = node;
@@ -7301,7 +7589,7 @@ var LinkedList = /** @class */ (function () {
7301
7589
  /**
7302
7590
  * The namespace for the module implementation details.
7303
7591
  */
7304
- var Private$n;
7592
+ var Private$m;
7305
7593
  (function (Private) {
7306
7594
  /**
7307
7595
  * The internal linked list node implementation.
@@ -7333,7 +7621,7 @@ var Private$n;
7333
7621
  return LinkedListNode;
7334
7622
  }());
7335
7623
  Private.LinkedListNode = LinkedListNode;
7336
- })(Private$n || (Private$n = {}));
7624
+ })(Private$m || (Private$m = {}));
7337
7625
 
7338
7626
  /*! *****************************************************************************
7339
7627
  Copyright (c) Microsoft Corporation.
@@ -7872,195 +8160,6 @@ var MessageLoop;
7872
8160
  }
7873
8161
  })(MessageLoop || (MessageLoop = {}));
7874
8162
 
7875
- // Copyright (c) Jupyter Development Team.
7876
- // Distributed under the terms of the Modified BSD License.
7877
- /*-----------------------------------------------------------------------------
7878
- | Copyright (c) 2014-2017, PhosphorJS Contributors
7879
- |
7880
- | Distributed under the terms of the BSD 3-Clause License.
7881
- |
7882
- | The full license is in the file LICENSE, distributed with this software.
7883
- |----------------------------------------------------------------------------*/
7884
- /**
7885
- * A class which attaches a value to an external object.
7886
- *
7887
- * #### Notes
7888
- * Attached properties are used to extend the state of an object with
7889
- * semantic data from an unrelated class. They also encapsulate value
7890
- * creation, coercion, and notification.
7891
- *
7892
- * Because attached property values are stored in a hash table, which
7893
- * in turn is stored in a WeakMap keyed on the owner object, there is
7894
- * non-trivial storage overhead involved in their use. The pattern is
7895
- * therefore best used for the storage of rare data.
7896
- */
7897
- var AttachedProperty = /** @class */ (function () {
7898
- /**
7899
- * Construct a new attached property.
7900
- *
7901
- * @param options - The options for initializing the property.
7902
- */
7903
- function AttachedProperty(options) {
7904
- this._pid = Private$m.nextPID();
7905
- this.name = options.name;
7906
- this._create = options.create;
7907
- this._coerce = options.coerce || null;
7908
- this._compare = options.compare || null;
7909
- this._changed = options.changed || null;
7910
- }
7911
- /**
7912
- * Get the current value of the property for a given owner.
7913
- *
7914
- * @param owner - The property owner of interest.
7915
- *
7916
- * @returns The current value of the property.
7917
- *
7918
- * #### Notes
7919
- * If the value has not yet been set, the default value will be
7920
- * computed and assigned as the current value of the property.
7921
- */
7922
- AttachedProperty.prototype.get = function (owner) {
7923
- var value;
7924
- var map = Private$m.ensureMap(owner);
7925
- if (this._pid in map) {
7926
- value = map[this._pid];
7927
- }
7928
- else {
7929
- value = map[this._pid] = this._createValue(owner);
7930
- }
7931
- return value;
7932
- };
7933
- /**
7934
- * Set the current value of the property for a given owner.
7935
- *
7936
- * @param owner - The property owner of interest.
7937
- *
7938
- * @param value - The value for the property.
7939
- *
7940
- * #### Notes
7941
- * If the value has not yet been set, the default value will be
7942
- * computed and used as the previous value for the comparison.
7943
- */
7944
- AttachedProperty.prototype.set = function (owner, value) {
7945
- var oldValue;
7946
- var map = Private$m.ensureMap(owner);
7947
- if (this._pid in map) {
7948
- oldValue = map[this._pid];
7949
- }
7950
- else {
7951
- oldValue = map[this._pid] = this._createValue(owner);
7952
- }
7953
- var newValue = this._coerceValue(owner, value);
7954
- this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
7955
- };
7956
- /**
7957
- * Explicitly coerce the current property value for a given owner.
7958
- *
7959
- * @param owner - The property owner of interest.
7960
- *
7961
- * #### Notes
7962
- * If the value has not yet been set, the default value will be
7963
- * computed and used as the previous value for the comparison.
7964
- */
7965
- AttachedProperty.prototype.coerce = function (owner) {
7966
- var oldValue;
7967
- var map = Private$m.ensureMap(owner);
7968
- if (this._pid in map) {
7969
- oldValue = map[this._pid];
7970
- }
7971
- else {
7972
- oldValue = map[this._pid] = this._createValue(owner);
7973
- }
7974
- var newValue = this._coerceValue(owner, oldValue);
7975
- this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
7976
- };
7977
- /**
7978
- * Get or create the default value for the given owner.
7979
- */
7980
- AttachedProperty.prototype._createValue = function (owner) {
7981
- var create = this._create;
7982
- return create(owner);
7983
- };
7984
- /**
7985
- * Coerce the value for the given owner.
7986
- */
7987
- AttachedProperty.prototype._coerceValue = function (owner, value) {
7988
- var coerce = this._coerce;
7989
- return coerce ? coerce(owner, value) : value;
7990
- };
7991
- /**
7992
- * Compare the old value and new value for equality.
7993
- */
7994
- AttachedProperty.prototype._compareValue = function (oldValue, newValue) {
7995
- var compare = this._compare;
7996
- return compare ? compare(oldValue, newValue) : oldValue === newValue;
7997
- };
7998
- /**
7999
- * Run the change notification if the given values are different.
8000
- */
8001
- AttachedProperty.prototype._maybeNotify = function (owner, oldValue, newValue) {
8002
- var changed = this._changed;
8003
- if (changed && !this._compareValue(oldValue, newValue)) {
8004
- changed(owner, oldValue, newValue);
8005
- }
8006
- };
8007
- return AttachedProperty;
8008
- }());
8009
- /**
8010
- * The namespace for the `AttachedProperty` class statics.
8011
- */
8012
- (function (AttachedProperty) {
8013
- /**
8014
- * Clear the stored property data for the given owner.
8015
- *
8016
- * @param owner - The property owner of interest.
8017
- *
8018
- * #### Notes
8019
- * This will clear all property values for the owner, but it will
8020
- * **not** run the change notification for any of the properties.
8021
- */
8022
- function clearData(owner) {
8023
- Private$m.ownerData.delete(owner);
8024
- }
8025
- AttachedProperty.clearData = clearData;
8026
- })(AttachedProperty || (AttachedProperty = {}));
8027
- /**
8028
- * The namespace for the module implementation details.
8029
- */
8030
- var Private$m;
8031
- (function (Private) {
8032
- /**
8033
- * A weak mapping of property owner to property map.
8034
- */
8035
- Private.ownerData = new WeakMap();
8036
- /**
8037
- * A function which computes successive unique property ids.
8038
- */
8039
- Private.nextPID = (function () {
8040
- var id = 0;
8041
- return function () {
8042
- var rand = Math.random();
8043
- var stem = ("" + rand).slice(2);
8044
- return "pid-" + stem + "-" + id++;
8045
- };
8046
- })();
8047
- /**
8048
- * Lookup the data map for the property owner.
8049
- *
8050
- * This will create the map if one does not already exist.
8051
- */
8052
- function ensureMap(owner) {
8053
- var map = Private.ownerData.get(owner);
8054
- if (map) {
8055
- return map;
8056
- }
8057
- map = Object.create(null);
8058
- Private.ownerData.set(owner, map);
8059
- return map;
8060
- }
8061
- Private.ensureMap = ensureMap;
8062
- })(Private$m || (Private$m = {}));
8063
-
8064
8163
  /**
8065
8164
  * An object which manages a drag-drop operation.
8066
8165
  *
@@ -9367,7 +9466,10 @@ var Private$k;
9367
9466
  }
9368
9467
  // Handle the simplest case of in-place text update first.
9369
9468
  if (oldVNode.type === 'text' && newVNode.type === 'text') {
9370
- currElem.textContent = newVNode.content;
9469
+ // Avoid spurious updates for performance.
9470
+ if (currElem.textContent !== newVNode.content) {
9471
+ currElem.textContent = newVNode.content;
9472
+ }
9371
9473
  currElem = currElem.nextSibling;
9372
9474
  continue;
9373
9475
  }
@@ -9673,15 +9775,15 @@ function __extends$4(d, b) {
9673
9775
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9674
9776
  }
9675
9777
 
9676
- var __assign$1 = function() {
9677
- __assign$1 = Object.assign || function __assign(t) {
9778
+ var __assign$2 = function() {
9779
+ __assign$2 = Object.assign || function __assign(t) {
9678
9780
  for (var s, i = 1, n = arguments.length; i < n; i++) {
9679
9781
  s = arguments[i];
9680
9782
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9681
9783
  }
9682
9784
  return t;
9683
9785
  };
9684
- return __assign$1.apply(this, arguments);
9786
+ return __assign$2.apply(this, arguments);
9685
9787
  };
9686
9788
 
9687
9789
  function __rest(s, e) {
@@ -13318,7 +13420,7 @@ var AccordionLayout = /** @class */ (function (_super) {
13318
13420
  * Titles must be rotated for horizontal accordion panel using CSS: see accordionpanel.css
13319
13421
  */
13320
13422
  function AccordionLayout(options) {
13321
- var _this = _super.call(this, __assign$1(__assign$1({}, options), { orientation: options.orientation || 'vertical' })) || this;
13423
+ var _this = _super.call(this, __assign$2(__assign$2({}, options), { orientation: options.orientation || 'vertical' })) || this;
13322
13424
  _this._titles = [];
13323
13425
  _this.titleSpace = options.titleSpace || 22;
13324
13426
  return _this;
@@ -13973,7 +14075,7 @@ var AccordionPanel = /** @class */ (function (_super) {
13973
14075
  */
13974
14076
  function AccordionPanel(options) {
13975
14077
  if (options === void 0) { options = {}; }
13976
- var _this = _super.call(this, __assign$1(__assign$1({}, options), { layout: Private$d.createLayout(options) })) || this;
14078
+ var _this = _super.call(this, __assign$2(__assign$2({}, options), { layout: Private$d.createLayout(options) })) || this;
13977
14079
  _this._widgetSizesCache = new WeakMap();
13978
14080
  _this.addClass('lm-AccordionPanel');
13979
14081
  return _this;
@@ -15702,7 +15804,7 @@ var CommandPalette = /** @class */ (function (_super) {
15702
15804
  * @returns The dataset for the command palette item.
15703
15805
  */
15704
15806
  Renderer.prototype.createItemDataset = function (data) {
15705
- return __assign$1(__assign$1({}, data.item.dataset), { command: data.item.command });
15807
+ return __assign$2(__assign$2({}, data.item.dataset), { command: data.item.command });
15706
15808
  };
15707
15809
  /**
15708
15810
  * Create the class name for the command item icon.
@@ -15751,9 +15853,7 @@ var CommandPalette = /** @class */ (function (_super) {
15751
15853
  */
15752
15854
  Renderer.prototype.formatItemShortcut = function (data) {
15753
15855
  var kb = data.item.keyBinding;
15754
- return kb
15755
- ? kb.keys.map(CommandRegistry.formatKeystroke).join(', ')
15756
- : null;
15856
+ return kb ? CommandRegistry.formatKeystroke(kb.keys) : null;
15757
15857
  };
15758
15858
  /**
15759
15859
  * Create the render content for the item label node.
@@ -16954,6 +17054,8 @@ var Menu = /** @class */ (function (_super) {
16954
17054
  if (submenu === this._childMenu) {
16955
17055
  return;
16956
17056
  }
17057
+ // Prior to any DOM modifications save window data
17058
+ Menu.saveWindowData();
16957
17059
  // Ensure the current child menu is closed.
16958
17060
  this._closeChildMenu();
16959
17061
  // Update the private child state.
@@ -17026,6 +17128,18 @@ var Menu = /** @class */ (function (_super) {
17026
17128
  this._closeTimerID = 0;
17027
17129
  }
17028
17130
  };
17131
+ /**
17132
+ * Save window data used for menu positioning in transient cache.
17133
+ *
17134
+ * In order to avoid layout trashing it is recommended to invoke this
17135
+ * method immediately prior to opening the menu and any DOM modifications
17136
+ * (like closing previously visible menu, or adding a class to menu widget).
17137
+ *
17138
+ * The transient cache will be released upon `open()` call.
17139
+ */
17140
+ Menu.saveWindowData = function () {
17141
+ Private$9.saveWindowData();
17142
+ };
17029
17143
  return Menu;
17030
17144
  }(Widget));
17031
17145
  /**
@@ -17052,7 +17166,7 @@ var Menu = /** @class */ (function (_super) {
17052
17166
  var className = this.createItemClass(data);
17053
17167
  var dataset = this.createItemDataset(data);
17054
17168
  var aria = this.createItemARIA(data);
17055
- return h.li(__assign$1({ className: className,
17169
+ return h.li(__assign$2({ className: className,
17056
17170
  dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data), this.renderShortcut(data), this.renderSubmenu(data));
17057
17171
  };
17058
17172
  /**
@@ -17182,10 +17296,10 @@ var Menu = /** @class */ (function (_super) {
17182
17296
  var result;
17183
17297
  var _a = data.item, type = _a.type, command = _a.command, dataset = _a.dataset;
17184
17298
  if (type === 'command') {
17185
- result = __assign$1(__assign$1({}, dataset), { type: type, command: command });
17299
+ result = __assign$2(__assign$2({}, dataset), { type: type, command: command });
17186
17300
  }
17187
17301
  else {
17188
- result = __assign$1(__assign$1({}, dataset), { type: type });
17302
+ result = __assign$2(__assign$2({}, dataset), { type: type });
17189
17303
  }
17190
17304
  return result;
17191
17305
  };
@@ -17268,9 +17382,7 @@ var Menu = /** @class */ (function (_super) {
17268
17382
  */
17269
17383
  Renderer.prototype.formatShortcut = function (data) {
17270
17384
  var kb = data.item.keyBinding;
17271
- return kb
17272
- ? kb.keys.map(CommandRegistry.formatKeystroke).join(', ')
17273
- : null;
17385
+ return kb ? CommandRegistry.formatKeystroke(kb.keys) : null;
17274
17386
  };
17275
17387
  return Renderer;
17276
17388
  }());
@@ -17293,6 +17405,30 @@ var Private$9;
17293
17405
  * The horizontal pixel overlap for an open submenu.
17294
17406
  */
17295
17407
  Private.SUBMENU_OVERLAP = 3;
17408
+ var transientWindowDataCache = null;
17409
+ var transientCacheCounter = 0;
17410
+ function getWindowData() {
17411
+ // if transient cache is in use, take one from it
17412
+ if (transientCacheCounter > 0) {
17413
+ transientCacheCounter--;
17414
+ return transientWindowDataCache;
17415
+ }
17416
+ return _getWindowData();
17417
+ }
17418
+ /**
17419
+ * Store window data in transient cache.
17420
+ *
17421
+ * The transient cache will be released upon `getWindowData()` call.
17422
+ * If this function is called multiple times, the cache will be
17423
+ * retained until as many calls to `getWindowData()` were made.
17424
+ *
17425
+ * Note: should be called before any DOM modifications.
17426
+ */
17427
+ function saveWindowData() {
17428
+ transientWindowDataCache = _getWindowData();
17429
+ transientCacheCounter++;
17430
+ }
17431
+ Private.saveWindowData = saveWindowData;
17296
17432
  /**
17297
17433
  * Create the DOM node for a menu.
17298
17434
  */
@@ -17388,28 +17524,33 @@ var Private$9;
17388
17524
  return result;
17389
17525
  }
17390
17526
  Private.computeCollapsed = computeCollapsed;
17527
+ function _getWindowData() {
17528
+ return {
17529
+ pageXOffset: window.pageXOffset,
17530
+ pageYOffset: window.pageYOffset,
17531
+ clientWidth: document.documentElement.clientWidth,
17532
+ clientHeight: document.documentElement.clientHeight
17533
+ };
17534
+ }
17391
17535
  /**
17392
17536
  * Open a menu as a root menu at the target location.
17393
17537
  */
17394
17538
  function openRootMenu(menu, x, y, forceX, forceY) {
17539
+ // Get the current position and size of the main viewport.
17540
+ var windowData = getWindowData();
17541
+ var px = windowData.pageXOffset;
17542
+ var py = windowData.pageYOffset;
17543
+ var cw = windowData.clientWidth;
17544
+ var ch = windowData.clientHeight;
17395
17545
  // Ensure the menu is updated before attaching and measuring.
17396
17546
  MessageLoop.sendMessage(menu, Widget.Msg.UpdateRequest);
17397
- // Get the current position and size of the main viewport.
17398
- var px = window.pageXOffset;
17399
- var py = window.pageYOffset;
17400
- var cw = document.documentElement.clientWidth;
17401
- var ch = document.documentElement.clientHeight;
17402
17547
  // Compute the maximum allowed height for the menu.
17403
17548
  var maxHeight = ch - (forceY ? y : 0);
17404
17549
  // Fetch common variables.
17405
17550
  var node = menu.node;
17406
17551
  var style = node.style;
17407
17552
  // Clear the menu geometry and prepare it for measuring.
17408
- style.top = '';
17409
- style.left = '';
17410
- style.width = '';
17411
- style.height = '';
17412
- style.visibility = 'hidden';
17553
+ style.opacity = '0';
17413
17554
  style.maxHeight = maxHeight + "px";
17414
17555
  // Attach the menu to the document.
17415
17556
  Widget.attach(menu, document.body);
@@ -17429,34 +17570,30 @@ var Private$9;
17429
17570
  }
17430
17571
  }
17431
17572
  // Update the position of the menu to the computed position.
17432
- style.top = Math.max(0, y) + "px";
17433
- style.left = Math.max(0, x) + "px";
17573
+ style.transform = "translate(" + Math.max(0, x) + "px, " + Math.max(0, y) + "px";
17434
17574
  // Finally, make the menu visible on the screen.
17435
- style.visibility = '';
17575
+ style.opacity = '1';
17436
17576
  }
17437
17577
  Private.openRootMenu = openRootMenu;
17438
17578
  /**
17439
17579
  * Open a menu as a submenu using an item node for positioning.
17440
17580
  */
17441
17581
  function openSubmenu(submenu, itemNode) {
17582
+ // Get the current position and size of the main viewport.
17583
+ var windowData = getWindowData();
17584
+ var px = windowData.pageXOffset;
17585
+ var py = windowData.pageYOffset;
17586
+ var cw = windowData.clientWidth;
17587
+ var ch = windowData.clientHeight;
17442
17588
  // Ensure the menu is updated before opening.
17443
17589
  MessageLoop.sendMessage(submenu, Widget.Msg.UpdateRequest);
17444
- // Get the current position and size of the main viewport.
17445
- var px = window.pageXOffset;
17446
- var py = window.pageYOffset;
17447
- var cw = document.documentElement.clientWidth;
17448
- var ch = document.documentElement.clientHeight;
17449
17590
  // Compute the maximum allowed height for the menu.
17450
17591
  var maxHeight = ch;
17451
17592
  // Fetch common variables.
17452
17593
  var node = submenu.node;
17453
17594
  var style = node.style;
17454
17595
  // Clear the menu geometry and prepare it for measuring.
17455
- style.top = '';
17456
- style.left = '';
17457
- style.width = '';
17458
- style.height = '';
17459
- style.visibility = 'hidden';
17596
+ style.opacity = '0';
17460
17597
  style.maxHeight = maxHeight + "px";
17461
17598
  // Attach the menu to the document.
17462
17599
  Widget.attach(submenu, document.body);
@@ -17479,10 +17616,9 @@ var Private$9;
17479
17616
  y = itemRect.bottom + box.borderBottom + box.paddingBottom - height;
17480
17617
  }
17481
17618
  // Update the position of the menu to the computed position.
17482
- style.top = Math.max(0, y) + "px";
17483
- style.left = Math.max(0, x) + "px";
17619
+ style.transform = "translate(" + Math.max(0, x) + "px, " + Math.max(0, y) + "px";
17484
17620
  // Finally, make the menu visible on the screen.
17485
- style.visibility = '';
17621
+ style.opacity = '1';
17486
17622
  }
17487
17623
  Private.openSubmenu = openSubmenu;
17488
17624
  /**
@@ -17806,6 +17942,8 @@ var ContextMenu = /** @class */ (function () {
17806
17942
  */
17807
17943
  ContextMenu.prototype.open = function (event) {
17808
17944
  var _this = this;
17945
+ // Prior to any DOM modifications update the window data.
17946
+ Menu.saveWindowData();
17809
17947
  // Clear the current contents of the context menu.
17810
17948
  this.menu.clearItems();
17811
17949
  // Bail early if there are no items to match.
@@ -17840,7 +17978,7 @@ var Private$8;
17840
17978
  function createItem(options, id) {
17841
17979
  var selector = validateSelector(options.selector);
17842
17980
  var rank = options.rank !== undefined ? options.rank : Infinity;
17843
- return __assign$1(__assign$1({}, options), { selector: selector, rank: rank, id: id });
17981
+ return __assign$2(__assign$2({}, options), { selector: selector, rank: rank, id: id });
17844
17982
  }
17845
17983
  Private.createItem = createItem;
17846
17984
  /**
@@ -19088,10 +19226,10 @@ var TabBar = /** @class */ (function (_super) {
19088
19226
  var dataset = this.createTabDataset(data);
19089
19227
  var aria = this.createTabARIA(data);
19090
19228
  if (data.title.closable) {
19091
- return h.li(__assign$1({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data), this.renderCloseIcon(data));
19229
+ return h.li(__assign$2({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data), this.renderCloseIcon(data));
19092
19230
  }
19093
19231
  else {
19094
- return h.li(__assign$1({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data));
19232
+ return h.li(__assign$2({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data));
19095
19233
  }
19096
19234
  };
19097
19235
  /**
@@ -23734,13 +23872,20 @@ var MenuBar = /** @class */ (function (_super) {
23734
23872
  };
23735
23873
  /**
23736
23874
  * Handle the `'keydown'` event for the menu bar.
23875
+ *
23876
+ * #### Notes
23877
+ * All keys are trapped except the tab key that is ignored.
23737
23878
  */
23738
23879
  MenuBar.prototype._evtKeyDown = function (event) {
23739
- // A menu bar handles all keydown events.
23740
- event.preventDefault();
23741
- event.stopPropagation();
23742
23880
  // Fetch the key code for the event.
23743
23881
  var kc = event.keyCode;
23882
+ // Do not trap the tab key.
23883
+ if (kc === 9) {
23884
+ return;
23885
+ }
23886
+ // A menu bar handles all other keydown events.
23887
+ event.preventDefault();
23888
+ event.stopPropagation();
23744
23889
  // Enter, Up Arrow, Down Arrow
23745
23890
  if (kc === 13 || kc === 38 || kc === 40) {
23746
23891
  this.openActiveMenu();
@@ -23824,8 +23969,11 @@ var MenuBar = /** @class */ (function (_super) {
23824
23969
  this.activeIndex = index;
23825
23970
  }
23826
23971
  else {
23972
+ var position = this._positionForMenu(index);
23973
+ Menu.saveWindowData();
23974
+ // Begin DOM modifications.
23827
23975
  this.activeIndex = index;
23828
- this._openChildMenu();
23976
+ this._openChildMenu(position);
23829
23977
  }
23830
23978
  };
23831
23979
  /**
@@ -23846,13 +23994,33 @@ var MenuBar = /** @class */ (function (_super) {
23846
23994
  if (index === -1 && this._childMenu) {
23847
23995
  return;
23848
23996
  }
23997
+ // Get position for the new menu >before< updating active index.
23998
+ var position = this._positionForMenu(index);
23999
+ // Before any modification, update window data.
24000
+ Menu.saveWindowData();
24001
+ // Begin DOM modifications.
23849
24002
  // Update the active index to the hovered item.
23850
24003
  this.activeIndex = index;
23851
24004
  // Open the new menu if a menu is already open.
23852
24005
  if (this._childMenu) {
23853
- this._openChildMenu();
24006
+ this._openChildMenu(position);
23854
24007
  }
23855
24008
  };
24009
+ /**
24010
+ * Find initial position for the menu based on menubar item position.
24011
+ *
24012
+ * NOTE: this should be called before updating active index to avoid
24013
+ * an additional layout and style invalidation as changing active
24014
+ * index modifies DOM.
24015
+ */
24016
+ MenuBar.prototype._positionForMenu = function (index) {
24017
+ var itemNode = this.contentNode.children[index];
24018
+ var _a = itemNode.getBoundingClientRect(), left = _a.left, bottom = _a.bottom;
24019
+ return {
24020
+ top: bottom,
24021
+ left: left
24022
+ };
24023
+ };
23856
24024
  /**
23857
24025
  * Handle the `'mouseleave'` event for the menu bar.
23858
24026
  */
@@ -23868,7 +24036,9 @@ var MenuBar = /** @class */ (function (_super) {
23868
24036
  * If a different child menu is already open, it will be closed,
23869
24037
  * even if there is no active menu.
23870
24038
  */
23871
- MenuBar.prototype._openChildMenu = function () {
24039
+ MenuBar.prototype._openChildMenu = function (options) {
24040
+ var _a;
24041
+ if (options === void 0) { options = {}; }
23872
24042
  // If there is no active menu, close the current menu.
23873
24043
  var newMenu = this.activeMenu;
23874
24044
  if (!newMenu) {
@@ -23887,20 +24057,26 @@ var MenuBar = /** @class */ (function (_super) {
23887
24057
  oldMenu.close();
23888
24058
  }
23889
24059
  else {
23890
- this.addClass('lm-mod-active');
23891
- /* <DEPRECATED> */
23892
- this.addClass('p-mod-active');
23893
- /* </DEPRECATED> */
23894
24060
  document.addEventListener('mousedown', this, true);
23895
24061
  }
23896
24062
  // Ensure the menu bar is updated and look up the item node.
23897
24063
  MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);
23898
- var itemNode = this.contentNode.children[this._activeIndex];
23899
24064
  // Get the positioning data for the new menu.
23900
- var _a = itemNode.getBoundingClientRect(), left = _a.left, bottom = _a.bottom;
24065
+ var left = options.left, top = options.top;
24066
+ if (typeof left === 'undefined' || typeof top === 'undefined') {
24067
+ (_a = this._positionForMenu(this._activeIndex), left = _a.left, top = _a.top);
24068
+ }
24069
+ // Begin DOM modifications
24070
+ if (!oldMenu) {
24071
+ // Continue setup for new menu
24072
+ this.addClass('lm-mod-active');
24073
+ /* <DEPRECATED> */
24074
+ this.addClass('p-mod-active');
24075
+ /* </DEPRECATED> */
24076
+ }
23901
24077
  // Open the new menu at the computed location.
23902
24078
  if (newMenu.items.length > 0) {
23903
- newMenu.open(left, bottom, this._forceItemsPosition);
24079
+ newMenu.open(left, top, this._forceItemsPosition);
23904
24080
  }
23905
24081
  };
23906
24082
  /**
@@ -24003,7 +24179,7 @@ var MenuBar = /** @class */ (function (_super) {
24003
24179
  var className = this.createItemClass(data);
24004
24180
  var dataset = this.createItemDataset(data);
24005
24181
  var aria = this.createItemARIA(data);
24006
- return h.li(__assign$1({ className: className, dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data));
24182
+ return h.li(__assign$2({ className: className, dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data));
24007
24183
  };
24008
24184
  /**
24009
24185
  * Render the icon element for a menu bar item.