@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.js CHANGED
@@ -5,8 +5,8 @@
5
5
  })(this, (function (exports, common) { 'use strict';
6
6
 
7
7
  var PKG_NAME = "@hpcc-js/phosphor";
8
- var PKG_VERSION = "2.16.6";
9
- var BUILD_VERSION = "2.104.13";
8
+ var PKG_VERSION = "2.16.7";
9
+ var BUILD_VERSION = "2.104.14";
10
10
 
11
11
  // Copyright (c) Jupyter Development Team.
12
12
  // Distributed under the terms of the Modified BSD License.
@@ -2827,6 +2827,195 @@
2827
2827
  UUID.uuid4 = uuid4Factory(Random.getRandomValues);
2828
2828
  })(UUID || (UUID = {}));
2829
2829
 
2830
+ // Copyright (c) Jupyter Development Team.
2831
+ // Distributed under the terms of the Modified BSD License.
2832
+ /*-----------------------------------------------------------------------------
2833
+ | Copyright (c) 2014-2017, PhosphorJS Contributors
2834
+ |
2835
+ | Distributed under the terms of the BSD 3-Clause License.
2836
+ |
2837
+ | The full license is in the file LICENSE, distributed with this software.
2838
+ |----------------------------------------------------------------------------*/
2839
+ /**
2840
+ * A class which attaches a value to an external object.
2841
+ *
2842
+ * #### Notes
2843
+ * Attached properties are used to extend the state of an object with
2844
+ * semantic data from an unrelated class. They also encapsulate value
2845
+ * creation, coercion, and notification.
2846
+ *
2847
+ * Because attached property values are stored in a hash table, which
2848
+ * in turn is stored in a WeakMap keyed on the owner object, there is
2849
+ * non-trivial storage overhead involved in their use. The pattern is
2850
+ * therefore best used for the storage of rare data.
2851
+ */
2852
+ var AttachedProperty = /** @class */ (function () {
2853
+ /**
2854
+ * Construct a new attached property.
2855
+ *
2856
+ * @param options - The options for initializing the property.
2857
+ */
2858
+ function AttachedProperty(options) {
2859
+ this._pid = Private$r.nextPID();
2860
+ this.name = options.name;
2861
+ this._create = options.create;
2862
+ this._coerce = options.coerce || null;
2863
+ this._compare = options.compare || null;
2864
+ this._changed = options.changed || null;
2865
+ }
2866
+ /**
2867
+ * Get the current value of the property for a given owner.
2868
+ *
2869
+ * @param owner - The property owner of interest.
2870
+ *
2871
+ * @returns The current value of the property.
2872
+ *
2873
+ * #### Notes
2874
+ * If the value has not yet been set, the default value will be
2875
+ * computed and assigned as the current value of the property.
2876
+ */
2877
+ AttachedProperty.prototype.get = function (owner) {
2878
+ var value;
2879
+ var map = Private$r.ensureMap(owner);
2880
+ if (this._pid in map) {
2881
+ value = map[this._pid];
2882
+ }
2883
+ else {
2884
+ value = map[this._pid] = this._createValue(owner);
2885
+ }
2886
+ return value;
2887
+ };
2888
+ /**
2889
+ * Set the current value of the property for a given owner.
2890
+ *
2891
+ * @param owner - The property owner of interest.
2892
+ *
2893
+ * @param value - The value for the property.
2894
+ *
2895
+ * #### Notes
2896
+ * If the value has not yet been set, the default value will be
2897
+ * computed and used as the previous value for the comparison.
2898
+ */
2899
+ AttachedProperty.prototype.set = function (owner, value) {
2900
+ var oldValue;
2901
+ var map = Private$r.ensureMap(owner);
2902
+ if (this._pid in map) {
2903
+ oldValue = map[this._pid];
2904
+ }
2905
+ else {
2906
+ oldValue = map[this._pid] = this._createValue(owner);
2907
+ }
2908
+ var newValue = this._coerceValue(owner, value);
2909
+ this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
2910
+ };
2911
+ /**
2912
+ * Explicitly coerce the current property value for a given owner.
2913
+ *
2914
+ * @param owner - The property owner of interest.
2915
+ *
2916
+ * #### Notes
2917
+ * If the value has not yet been set, the default value will be
2918
+ * computed and used as the previous value for the comparison.
2919
+ */
2920
+ AttachedProperty.prototype.coerce = function (owner) {
2921
+ var oldValue;
2922
+ var map = Private$r.ensureMap(owner);
2923
+ if (this._pid in map) {
2924
+ oldValue = map[this._pid];
2925
+ }
2926
+ else {
2927
+ oldValue = map[this._pid] = this._createValue(owner);
2928
+ }
2929
+ var newValue = this._coerceValue(owner, oldValue);
2930
+ this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
2931
+ };
2932
+ /**
2933
+ * Get or create the default value for the given owner.
2934
+ */
2935
+ AttachedProperty.prototype._createValue = function (owner) {
2936
+ var create = this._create;
2937
+ return create(owner);
2938
+ };
2939
+ /**
2940
+ * Coerce the value for the given owner.
2941
+ */
2942
+ AttachedProperty.prototype._coerceValue = function (owner, value) {
2943
+ var coerce = this._coerce;
2944
+ return coerce ? coerce(owner, value) : value;
2945
+ };
2946
+ /**
2947
+ * Compare the old value and new value for equality.
2948
+ */
2949
+ AttachedProperty.prototype._compareValue = function (oldValue, newValue) {
2950
+ var compare = this._compare;
2951
+ return compare ? compare(oldValue, newValue) : oldValue === newValue;
2952
+ };
2953
+ /**
2954
+ * Run the change notification if the given values are different.
2955
+ */
2956
+ AttachedProperty.prototype._maybeNotify = function (owner, oldValue, newValue) {
2957
+ var changed = this._changed;
2958
+ if (changed && !this._compareValue(oldValue, newValue)) {
2959
+ changed(owner, oldValue, newValue);
2960
+ }
2961
+ };
2962
+ return AttachedProperty;
2963
+ }());
2964
+ /**
2965
+ * The namespace for the `AttachedProperty` class statics.
2966
+ */
2967
+ (function (AttachedProperty) {
2968
+ /**
2969
+ * Clear the stored property data for the given owner.
2970
+ *
2971
+ * @param owner - The property owner of interest.
2972
+ *
2973
+ * #### Notes
2974
+ * This will clear all property values for the owner, but it will
2975
+ * **not** run the change notification for any of the properties.
2976
+ */
2977
+ function clearData(owner) {
2978
+ Private$r.ownerData.delete(owner);
2979
+ }
2980
+ AttachedProperty.clearData = clearData;
2981
+ })(AttachedProperty || (AttachedProperty = {}));
2982
+ /**
2983
+ * The namespace for the module implementation details.
2984
+ */
2985
+ var Private$r;
2986
+ (function (Private) {
2987
+ /**
2988
+ * A weak mapping of property owner to property map.
2989
+ */
2990
+ Private.ownerData = new WeakMap();
2991
+ /**
2992
+ * A function which computes successive unique property ids.
2993
+ */
2994
+ Private.nextPID = (function () {
2995
+ var id = 0;
2996
+ return function () {
2997
+ var rand = Math.random();
2998
+ var stem = ("" + rand).slice(2);
2999
+ return "pid-" + stem + "-" + id++;
3000
+ };
3001
+ })();
3002
+ /**
3003
+ * Lookup the data map for the property owner.
3004
+ *
3005
+ * This will create the map if one does not already exist.
3006
+ */
3007
+ function ensureMap(owner) {
3008
+ var map = Private.ownerData.get(owner);
3009
+ if (map) {
3010
+ return map;
3011
+ }
3012
+ map = Object.create(null);
3013
+ Private.ownerData.set(owner, map);
3014
+ return map;
3015
+ }
3016
+ Private.ensureMap = ensureMap;
3017
+ })(Private$r || (Private$r = {}));
3018
+
2830
3019
  // Copyright (c) Jupyter Development Team.
2831
3020
  /**
2832
3021
  * A concrete implementation of `ISignal`.
@@ -2884,8 +3073,26 @@
2884
3073
  * @param sender - The sender which owns the signal.
2885
3074
  */
2886
3075
  function Signal(sender) {
3076
+ this._blockedCount = 0;
2887
3077
  this.sender = sender;
2888
3078
  }
3079
+ /**
3080
+ * Block the signal during the execution of a callback.
3081
+ *
3082
+ * ### Notes
3083
+ * The callback function must be synchronous.
3084
+ *
3085
+ * @param fn The callback during which the signal is blocked
3086
+ */
3087
+ Signal.prototype.block = function (fn) {
3088
+ this._blockedCount++;
3089
+ try {
3090
+ fn();
3091
+ }
3092
+ finally {
3093
+ this._blockedCount--;
3094
+ }
3095
+ };
2889
3096
  /**
2890
3097
  * Connect a slot to the signal.
2891
3098
  *
@@ -2897,7 +3104,7 @@
2897
3104
  * @returns `true` if the connection succeeds, `false` otherwise.
2898
3105
  */
2899
3106
  Signal.prototype.connect = function (slot, thisArg) {
2900
- return Private$r.connect(this, slot, thisArg);
3107
+ return Private$q.connect(this, slot, thisArg);
2901
3108
  };
2902
3109
  /**
2903
3110
  * Disconnect a slot from the signal.
@@ -2910,7 +3117,7 @@
2910
3117
  * @returns `true` if the connection is removed, `false` otherwise.
2911
3118
  */
2912
3119
  Signal.prototype.disconnect = function (slot, thisArg) {
2913
- return Private$r.disconnect(this, slot, thisArg);
3120
+ return Private$q.disconnect(this, slot, thisArg);
2914
3121
  };
2915
3122
  /**
2916
3123
  * Emit the signal and invoke the connected slots.
@@ -2923,7 +3130,9 @@
2923
3130
  * Exceptions thrown by connected slots will be caught and logged.
2924
3131
  */
2925
3132
  Signal.prototype.emit = function (args) {
2926
- Private$r.emit(this, args);
3133
+ if (!this._blockedCount) {
3134
+ Private$q.emit(this, args);
3135
+ }
2927
3136
  };
2928
3137
  return Signal;
2929
3138
  }());
@@ -2931,6 +3140,27 @@
2931
3140
  * The namespace for the `Signal` class statics.
2932
3141
  */
2933
3142
  (function (Signal) {
3143
+ /**
3144
+ * Block all signals emitted by an object during
3145
+ * the execution of a callback.
3146
+ *
3147
+ * ### Notes
3148
+ * The callback function must be synchronous.
3149
+ *
3150
+ * @param sender The signals sender
3151
+ * @param fn The callback during which all signals are blocked
3152
+ */
3153
+ function blockAll(sender, fn) {
3154
+ var blockedProperty = Private$q.blockedProperty;
3155
+ blockedProperty.set(sender, blockedProperty.get(sender) + 1);
3156
+ try {
3157
+ fn();
3158
+ }
3159
+ finally {
3160
+ blockedProperty.set(sender, blockedProperty.get(sender) - 1);
3161
+ }
3162
+ }
3163
+ Signal.blockAll = blockAll;
2934
3164
  /**
2935
3165
  * Remove all connections between a sender and receiver.
2936
3166
  *
@@ -2944,7 +3174,7 @@
2944
3174
  * the receiver.
2945
3175
  */
2946
3176
  function disconnectBetween(sender, receiver) {
2947
- Private$r.disconnectBetween(sender, receiver);
3177
+ Private$q.disconnectBetween(sender, receiver);
2948
3178
  }
2949
3179
  Signal.disconnectBetween = disconnectBetween;
2950
3180
  /**
@@ -2953,7 +3183,7 @@
2953
3183
  * @param sender - The sender object of interest.
2954
3184
  */
2955
3185
  function disconnectSender(sender) {
2956
- Private$r.disconnectSender(sender);
3186
+ Private$q.disconnectSender(sender);
2957
3187
  }
2958
3188
  Signal.disconnectSender = disconnectSender;
2959
3189
  /**
@@ -2967,7 +3197,7 @@
2967
3197
  * the receiver.
2968
3198
  */
2969
3199
  function disconnectReceiver(receiver) {
2970
- Private$r.disconnectReceiver(receiver);
3200
+ Private$q.disconnectReceiver(receiver);
2971
3201
  }
2972
3202
  Signal.disconnectReceiver = disconnectReceiver;
2973
3203
  /**
@@ -2981,7 +3211,7 @@
2981
3211
  * the receiver.
2982
3212
  */
2983
3213
  function disconnectAll(object) {
2984
- Private$r.disconnectAll(object);
3214
+ Private$q.disconnectAll(object);
2985
3215
  }
2986
3216
  Signal.disconnectAll = disconnectAll;
2987
3217
  /**
@@ -2994,7 +3224,7 @@
2994
3224
  * associated with the object.
2995
3225
  */
2996
3226
  function clearData(object) {
2997
- Private$r.disconnectAll(object);
3227
+ Private$q.disconnectAll(object);
2998
3228
  }
2999
3229
  Signal.clearData = clearData;
3000
3230
  /**
@@ -3006,7 +3236,7 @@
3006
3236
  * The default exception handler is `console.error`.
3007
3237
  */
3008
3238
  function getExceptionHandler() {
3009
- return Private$r.exceptionHandler;
3239
+ return Private$q.exceptionHandler;
3010
3240
  }
3011
3241
  Signal.getExceptionHandler = getExceptionHandler;
3012
3242
  /**
@@ -3020,8 +3250,8 @@
3020
3250
  * The exception handler is invoked when a slot throws an exception.
3021
3251
  */
3022
3252
  function setExceptionHandler(handler) {
3023
- var old = Private$r.exceptionHandler;
3024
- Private$r.exceptionHandler = handler;
3253
+ var old = Private$q.exceptionHandler;
3254
+ Private$q.exceptionHandler = handler;
3025
3255
  return old;
3026
3256
  }
3027
3257
  Signal.setExceptionHandler = setExceptionHandler;
@@ -3029,7 +3259,7 @@
3029
3259
  /**
3030
3260
  * The namespace for the module implementation details.
3031
3261
  */
3032
- var Private$r;
3262
+ var Private$q;
3033
3263
  (function (Private) {
3034
3264
  /**
3035
3265
  * The signal exception handler function.
@@ -3230,6 +3460,9 @@
3230
3460
  * Exceptions thrown by connected slots will be caught and logged.
3231
3461
  */
3232
3462
  function emit(signal, args) {
3463
+ if (Private.blockedProperty.get(signal.sender) > 0) {
3464
+ return;
3465
+ }
3233
3466
  // If there are no receivers, there is nothing to do.
3234
3467
  var receivers = receiversForSender.get(signal.sender);
3235
3468
  if (!receivers || receivers.length === 0) {
@@ -3333,7 +3566,14 @@
3333
3566
  function isDeadConnection(connection) {
3334
3567
  return connection.signal === null;
3335
3568
  }
3336
- })(Private$r || (Private$r = {}));
3569
+ /**
3570
+ * A property indicating a sender has been blocked if its value is not 0.
3571
+ */
3572
+ Private.blockedProperty = new AttachedProperty({
3573
+ name: 'blocked',
3574
+ create: function () { return 0; }
3575
+ });
3576
+ })(Private$q || (Private$q = {}));
3337
3577
 
3338
3578
  /*! *****************************************************************************
3339
3579
  Copyright (c) Microsoft Corporation.
@@ -3838,11 +4078,11 @@
3838
4078
  * same selector are extremely fast.
3839
4079
  */
3840
4080
  function calculateSpecificity(selector) {
3841
- if (selector in Private$q.specificityCache) {
3842
- return Private$q.specificityCache[selector];
4081
+ if (selector in Private$p.specificityCache) {
4082
+ return Private$p.specificityCache[selector];
3843
4083
  }
3844
- var result = Private$q.calculateSingle(selector);
3845
- return (Private$q.specificityCache[selector] = result);
4084
+ var result = Private$p.calculateSingle(selector);
4085
+ return (Private$p.specificityCache[selector] = result);
3846
4086
  }
3847
4087
  Selector.calculateSpecificity = calculateSpecificity;
3848
4088
  /**
@@ -3857,17 +4097,17 @@
3857
4097
  * selector are extremely fast.
3858
4098
  */
3859
4099
  function isValid(selector) {
3860
- if (selector in Private$q.validityCache) {
3861
- return Private$q.validityCache[selector];
4100
+ if (selector in Private$p.validityCache) {
4101
+ return Private$p.validityCache[selector];
3862
4102
  }
3863
4103
  var result = true;
3864
4104
  try {
3865
- Private$q.testElem.querySelector(selector);
4105
+ Private$p.testElem.querySelector(selector);
3866
4106
  }
3867
4107
  catch (err) {
3868
4108
  result = false;
3869
4109
  }
3870
- return (Private$q.validityCache[selector] = result);
4110
+ return (Private$p.validityCache[selector] = result);
3871
4111
  }
3872
4112
  Selector.isValid = isValid;
3873
4113
  /**
@@ -3884,14 +4124,14 @@
3884
4124
  * falling back onto a document query otherwise.
3885
4125
  */
3886
4126
  function matches(element, selector) {
3887
- return Private$q.protoMatchFunc.call(element, selector);
4127
+ return Private$p.protoMatchFunc.call(element, selector);
3888
4128
  }
3889
4129
  Selector.matches = matches;
3890
4130
  })(Selector || (Selector = {}));
3891
4131
  /**
3892
4132
  * The namespace for the module implementation details.
3893
4133
  */
3894
- var Private$q;
4134
+ var Private$p;
3895
4135
  (function (Private) {
3896
4136
  /**
3897
4137
  * A cache of computed selector specificity values.
@@ -4029,7 +4269,7 @@
4029
4269
  * A regex which matches the negation pseudo-class globally.
4030
4270
  */
4031
4271
  var NEGATION_RE = /:not\(([^\)]+)\)/g;
4032
- })(Private$q || (Private$q = {}));
4272
+ })(Private$p || (Private$p = {}));
4033
4273
 
4034
4274
  // Copyright (c) Jupyter Development Team.
4035
4275
  // Distributed under the terms of the Modified BSD License.
@@ -4049,7 +4289,7 @@
4049
4289
  * The default keyboard layout is US-English.
4050
4290
  */
4051
4291
  function getKeyboardLayout() {
4052
- return Private$p.keyboardLayout;
4292
+ return Private$o.keyboardLayout;
4053
4293
  }
4054
4294
  /**
4055
4295
  * A concrete implementation of [[IKeyboardLayout]] based on keycodes.
@@ -4281,15 +4521,40 @@
4281
4521
  /**
4282
4522
  * The namespace for the module implementation details.
4283
4523
  */
4284
- var Private$p;
4524
+ var Private$o;
4285
4525
  (function (Private) {
4286
4526
  /**
4287
4527
  * The global keyboard layout instance.
4288
4528
  */
4289
4529
  Private.keyboardLayout = EN_US;
4290
- })(Private$p || (Private$p = {}));
4530
+ })(Private$o || (Private$o = {}));
4531
+
4532
+ /*! *****************************************************************************
4533
+ Copyright (c) Microsoft Corporation.
4534
+
4535
+ Permission to use, copy, modify, and/or distribute this software for any
4536
+ purpose with or without fee is hereby granted.
4537
+
4538
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
4539
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4540
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
4541
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4542
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
4543
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4544
+ PERFORMANCE OF THIS SOFTWARE.
4545
+ ***************************************************************************** */
4546
+
4547
+ var __assign$1 = function() {
4548
+ __assign$1 = Object.assign || function __assign(t) {
4549
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4550
+ s = arguments[i];
4551
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
4552
+ }
4553
+ return t;
4554
+ };
4555
+ return __assign$1.apply(this, arguments);
4556
+ };
4291
4557
 
4292
- // Copyright (c) Jupyter Development Team.
4293
4558
  /**
4294
4559
  * An object which manages a collection of commands.
4295
4560
  *
@@ -4395,7 +4660,7 @@
4395
4660
  throw new Error("Command '" + id + "' already registered.");
4396
4661
  }
4397
4662
  // Add the command to the registry.
4398
- this._commands[id] = Private$o.createCommand(options);
4663
+ this._commands[id] = Private$n.createCommand(options);
4399
4664
  // Emit the `commandChanged` signal.
4400
4665
  this._commandChanged.emit({ id: id, type: 'added' });
4401
4666
  // Return a disposable which will remove the command.
@@ -4427,6 +4692,17 @@
4427
4692
  }
4428
4693
  this._commandChanged.emit({ id: id, type: id ? 'changed' : 'many-changed' });
4429
4694
  };
4695
+ /**
4696
+ * Get the description for a specific command.
4697
+ *
4698
+ * @param id - The id of the command of interest.
4699
+ *
4700
+ * @returns The description for the command.
4701
+ */
4702
+ CommandRegistry.prototype.describedBy = function (id) {
4703
+ var cmd = this._commands[id];
4704
+ return cmd ? cmd.describedBy || { args: null } : { args: null };
4705
+ };
4430
4706
  /**
4431
4707
  * Get the display label for a specific command.
4432
4708
  *
@@ -4687,7 +4963,7 @@
4687
4963
  CommandRegistry.prototype.addKeyBinding = function (options) {
4688
4964
  var _this = this;
4689
4965
  // Create the binding for the given options.
4690
- var binding = Private$o.createKeyBinding(options);
4966
+ var binding = Private$n.createKeyBinding(options);
4691
4967
  // Add the key binding to the bindings array.
4692
4968
  this._keyBindings.push(binding);
4693
4969
  // Emit the `bindingChanged` signal.
@@ -4734,7 +5010,7 @@
4734
5010
  // Add the keystroke to the current key sequence.
4735
5011
  this._keystrokes.push(keystroke);
4736
5012
  // Find the exact and partial matches for the key sequence.
4737
- var _a = Private$o.matchKeyBinding(this._keyBindings, this._keystrokes, event), exact = _a.exact, partial = _a.partial;
5013
+ var _a = Private$n.matchKeyBinding(this._keyBindings, this._keystrokes, event), exact = _a.exact, partial = _a.partial;
4738
5014
  // If there is no exact match and no partial match, replay
4739
5015
  // any suppressed events and clear the pending state.
4740
5016
  if (!exact && !partial) {
@@ -4774,7 +5050,7 @@
4774
5050
  this._clearTimer();
4775
5051
  this._timerID = window.setTimeout(function () {
4776
5052
  _this._onPendingTimeout();
4777
- }, Private$o.CHORD_TIMEOUT);
5053
+ }, Private$n.CHORD_TIMEOUT);
4778
5054
  };
4779
5055
  /**
4780
5056
  * Clear the pending timeout.
@@ -4793,7 +5069,7 @@
4793
5069
  return;
4794
5070
  }
4795
5071
  this._replaying = true;
4796
- this._keydownEvents.forEach(Private$o.replayKeyEvent);
5072
+ this._keydownEvents.forEach(Private$n.replayKeyEvent);
4797
5073
  this._replaying = false;
4798
5074
  };
4799
5075
  /**
@@ -4951,26 +5227,37 @@
4951
5227
  }
4952
5228
  CommandRegistry.normalizeKeys = normalizeKeys;
4953
5229
  /**
4954
- * Format a keystroke for display on the local system.
5230
+ * Format keystrokes for display on the local system.
5231
+ *
5232
+ * If a list of keystrokes is provided, it will be displayed as
5233
+ * a comma-separated string
5234
+ *
5235
+ * @param keystroke The keystrokes to format
5236
+ * @returns The keystrokes representation
4955
5237
  */
4956
- function formatKeystroke(keystroke) {
4957
- var mods = [];
4958
- var separator = Platform.IS_MAC ? ' ' : '+';
4959
- var parts = parseKeystroke(keystroke);
4960
- if (parts.ctrl) {
4961
- mods.push('Ctrl');
4962
- }
4963
- if (parts.alt) {
4964
- mods.push('Alt');
4965
- }
4966
- if (parts.shift) {
4967
- mods.push('Shift');
4968
- }
4969
- if (Platform.IS_MAC && parts.cmd) {
4970
- mods.push('Cmd');
5238
+ function formatKeystroke(keystroke) {
5239
+ return typeof keystroke === 'string'
5240
+ ? formatSingleKey(keystroke)
5241
+ : keystroke.map(formatSingleKey).join(', ');
5242
+ function formatSingleKey(key) {
5243
+ var mods = [];
5244
+ var separator = Platform.IS_MAC ? ' ' : '+';
5245
+ var parts = parseKeystroke(key);
5246
+ if (parts.ctrl) {
5247
+ mods.push('Ctrl');
5248
+ }
5249
+ if (parts.alt) {
5250
+ mods.push('Alt');
5251
+ }
5252
+ if (parts.shift) {
5253
+ mods.push('Shift');
5254
+ }
5255
+ if (Platform.IS_MAC && parts.cmd) {
5256
+ mods.push('Cmd');
5257
+ }
5258
+ mods.push(parts.key);
5259
+ return mods.map(Private$n.formatKey).join(separator);
4971
5260
  }
4972
- mods.push(parts.key);
4973
- return mods.map(Private$o.formatKey).join(separator);
4974
5261
  }
4975
5262
  CommandRegistry.formatKeystroke = formatKeystroke;
4976
5263
  /**
@@ -5021,7 +5308,7 @@
5021
5308
  /**
5022
5309
  * The namespace for the module implementation details.
5023
5310
  */
5024
- var Private$o;
5311
+ var Private$n;
5025
5312
  (function (Private) {
5026
5313
  /**
5027
5314
  * The timeout in ms for triggering a key binding chord.
@@ -5048,6 +5335,7 @@
5048
5335
  /* </DEPRECATED> */
5049
5336
  return {
5050
5337
  execute: options.execute,
5338
+ describedBy: __assign$1({ args: null }, options.describedBy),
5051
5339
  label: asFunc(options.label, emptyStringFunc),
5052
5340
  mnemonic: asFunc(options.mnemonic, negativeOneFunc),
5053
5341
  icon: icon,
@@ -5293,7 +5581,7 @@
5293
5581
  clone.view = event.view || window;
5294
5582
  return clone;
5295
5583
  }
5296
- })(Private$o || (Private$o = {}));
5584
+ })(Private$n || (Private$n = {}));
5297
5585
 
5298
5586
  // Copyright (c) Jupyter Development Team.
5299
5587
  /**
@@ -6890,7 +7178,7 @@
6890
7178
  * Constant.
6891
7179
  */
6892
7180
  LinkedList.prototype.addFirst = function (value) {
6893
- var node = new Private$n.LinkedListNode(this, value);
7181
+ var node = new Private$m.LinkedListNode(this, value);
6894
7182
  if (!this._first) {
6895
7183
  this._first = node;
6896
7184
  this._last = node;
@@ -6914,7 +7202,7 @@
6914
7202
  * Constant.
6915
7203
  */
6916
7204
  LinkedList.prototype.addLast = function (value) {
6917
- var node = new Private$n.LinkedListNode(this, value);
7205
+ var node = new Private$m.LinkedListNode(this, value);
6918
7206
  if (!this._last) {
6919
7207
  this._first = node;
6920
7208
  this._last = node;
@@ -6947,10 +7235,10 @@
6947
7235
  if (!ref || ref === this._first) {
6948
7236
  return this.addFirst(value);
6949
7237
  }
6950
- if (!(ref instanceof Private$n.LinkedListNode) || ref.list !== this) {
7238
+ if (!(ref instanceof Private$m.LinkedListNode) || ref.list !== this) {
6951
7239
  throw new Error('Reference node is not owned by the list.');
6952
7240
  }
6953
- var node = new Private$n.LinkedListNode(this, value);
7241
+ var node = new Private$m.LinkedListNode(this, value);
6954
7242
  var _ref = ref;
6955
7243
  var prev = _ref.prev;
6956
7244
  node.next = _ref;
@@ -6980,10 +7268,10 @@
6980
7268
  if (!ref || ref === this._last) {
6981
7269
  return this.addLast(value);
6982
7270
  }
6983
- if (!(ref instanceof Private$n.LinkedListNode) || ref.list !== this) {
7271
+ if (!(ref instanceof Private$m.LinkedListNode) || ref.list !== this) {
6984
7272
  throw new Error('Reference node is not owned by the list.');
6985
7273
  }
6986
- var node = new Private$n.LinkedListNode(this, value);
7274
+ var node = new Private$m.LinkedListNode(this, value);
6987
7275
  var _ref = ref;
6988
7276
  var next = _ref.next;
6989
7277
  node.next = next;
@@ -7059,7 +7347,7 @@
7059
7347
  * The node must be owned by the list.
7060
7348
  */
7061
7349
  LinkedList.prototype.removeNode = function (node) {
7062
- if (!(node instanceof Private$n.LinkedListNode) || node.list !== this) {
7350
+ if (!(node instanceof Private$m.LinkedListNode) || node.list !== this) {
7063
7351
  throw new Error('Node is not owned by the list.');
7064
7352
  }
7065
7353
  var _node = node;
@@ -7305,7 +7593,7 @@
7305
7593
  /**
7306
7594
  * The namespace for the module implementation details.
7307
7595
  */
7308
- var Private$n;
7596
+ var Private$m;
7309
7597
  (function (Private) {
7310
7598
  /**
7311
7599
  * The internal linked list node implementation.
@@ -7337,7 +7625,7 @@
7337
7625
  return LinkedListNode;
7338
7626
  }());
7339
7627
  Private.LinkedListNode = LinkedListNode;
7340
- })(Private$n || (Private$n = {}));
7628
+ })(Private$m || (Private$m = {}));
7341
7629
 
7342
7630
  /*! *****************************************************************************
7343
7631
  Copyright (c) Microsoft Corporation.
@@ -7876,195 +8164,6 @@
7876
8164
  }
7877
8165
  })(MessageLoop || (MessageLoop = {}));
7878
8166
 
7879
- // Copyright (c) Jupyter Development Team.
7880
- // Distributed under the terms of the Modified BSD License.
7881
- /*-----------------------------------------------------------------------------
7882
- | Copyright (c) 2014-2017, PhosphorJS Contributors
7883
- |
7884
- | Distributed under the terms of the BSD 3-Clause License.
7885
- |
7886
- | The full license is in the file LICENSE, distributed with this software.
7887
- |----------------------------------------------------------------------------*/
7888
- /**
7889
- * A class which attaches a value to an external object.
7890
- *
7891
- * #### Notes
7892
- * Attached properties are used to extend the state of an object with
7893
- * semantic data from an unrelated class. They also encapsulate value
7894
- * creation, coercion, and notification.
7895
- *
7896
- * Because attached property values are stored in a hash table, which
7897
- * in turn is stored in a WeakMap keyed on the owner object, there is
7898
- * non-trivial storage overhead involved in their use. The pattern is
7899
- * therefore best used for the storage of rare data.
7900
- */
7901
- var AttachedProperty = /** @class */ (function () {
7902
- /**
7903
- * Construct a new attached property.
7904
- *
7905
- * @param options - The options for initializing the property.
7906
- */
7907
- function AttachedProperty(options) {
7908
- this._pid = Private$m.nextPID();
7909
- this.name = options.name;
7910
- this._create = options.create;
7911
- this._coerce = options.coerce || null;
7912
- this._compare = options.compare || null;
7913
- this._changed = options.changed || null;
7914
- }
7915
- /**
7916
- * Get the current value of the property for a given owner.
7917
- *
7918
- * @param owner - The property owner of interest.
7919
- *
7920
- * @returns The current value of the property.
7921
- *
7922
- * #### Notes
7923
- * If the value has not yet been set, the default value will be
7924
- * computed and assigned as the current value of the property.
7925
- */
7926
- AttachedProperty.prototype.get = function (owner) {
7927
- var value;
7928
- var map = Private$m.ensureMap(owner);
7929
- if (this._pid in map) {
7930
- value = map[this._pid];
7931
- }
7932
- else {
7933
- value = map[this._pid] = this._createValue(owner);
7934
- }
7935
- return value;
7936
- };
7937
- /**
7938
- * Set the current value of the property for a given owner.
7939
- *
7940
- * @param owner - The property owner of interest.
7941
- *
7942
- * @param value - The value for the property.
7943
- *
7944
- * #### Notes
7945
- * If the value has not yet been set, the default value will be
7946
- * computed and used as the previous value for the comparison.
7947
- */
7948
- AttachedProperty.prototype.set = function (owner, value) {
7949
- var oldValue;
7950
- var map = Private$m.ensureMap(owner);
7951
- if (this._pid in map) {
7952
- oldValue = map[this._pid];
7953
- }
7954
- else {
7955
- oldValue = map[this._pid] = this._createValue(owner);
7956
- }
7957
- var newValue = this._coerceValue(owner, value);
7958
- this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
7959
- };
7960
- /**
7961
- * Explicitly coerce the current property value for a given owner.
7962
- *
7963
- * @param owner - The property owner of interest.
7964
- *
7965
- * #### Notes
7966
- * If the value has not yet been set, the default value will be
7967
- * computed and used as the previous value for the comparison.
7968
- */
7969
- AttachedProperty.prototype.coerce = function (owner) {
7970
- var oldValue;
7971
- var map = Private$m.ensureMap(owner);
7972
- if (this._pid in map) {
7973
- oldValue = map[this._pid];
7974
- }
7975
- else {
7976
- oldValue = map[this._pid] = this._createValue(owner);
7977
- }
7978
- var newValue = this._coerceValue(owner, oldValue);
7979
- this._maybeNotify(owner, oldValue, (map[this._pid] = newValue));
7980
- };
7981
- /**
7982
- * Get or create the default value for the given owner.
7983
- */
7984
- AttachedProperty.prototype._createValue = function (owner) {
7985
- var create = this._create;
7986
- return create(owner);
7987
- };
7988
- /**
7989
- * Coerce the value for the given owner.
7990
- */
7991
- AttachedProperty.prototype._coerceValue = function (owner, value) {
7992
- var coerce = this._coerce;
7993
- return coerce ? coerce(owner, value) : value;
7994
- };
7995
- /**
7996
- * Compare the old value and new value for equality.
7997
- */
7998
- AttachedProperty.prototype._compareValue = function (oldValue, newValue) {
7999
- var compare = this._compare;
8000
- return compare ? compare(oldValue, newValue) : oldValue === newValue;
8001
- };
8002
- /**
8003
- * Run the change notification if the given values are different.
8004
- */
8005
- AttachedProperty.prototype._maybeNotify = function (owner, oldValue, newValue) {
8006
- var changed = this._changed;
8007
- if (changed && !this._compareValue(oldValue, newValue)) {
8008
- changed(owner, oldValue, newValue);
8009
- }
8010
- };
8011
- return AttachedProperty;
8012
- }());
8013
- /**
8014
- * The namespace for the `AttachedProperty` class statics.
8015
- */
8016
- (function (AttachedProperty) {
8017
- /**
8018
- * Clear the stored property data for the given owner.
8019
- *
8020
- * @param owner - The property owner of interest.
8021
- *
8022
- * #### Notes
8023
- * This will clear all property values for the owner, but it will
8024
- * **not** run the change notification for any of the properties.
8025
- */
8026
- function clearData(owner) {
8027
- Private$m.ownerData.delete(owner);
8028
- }
8029
- AttachedProperty.clearData = clearData;
8030
- })(AttachedProperty || (AttachedProperty = {}));
8031
- /**
8032
- * The namespace for the module implementation details.
8033
- */
8034
- var Private$m;
8035
- (function (Private) {
8036
- /**
8037
- * A weak mapping of property owner to property map.
8038
- */
8039
- Private.ownerData = new WeakMap();
8040
- /**
8041
- * A function which computes successive unique property ids.
8042
- */
8043
- Private.nextPID = (function () {
8044
- var id = 0;
8045
- return function () {
8046
- var rand = Math.random();
8047
- var stem = ("" + rand).slice(2);
8048
- return "pid-" + stem + "-" + id++;
8049
- };
8050
- })();
8051
- /**
8052
- * Lookup the data map for the property owner.
8053
- *
8054
- * This will create the map if one does not already exist.
8055
- */
8056
- function ensureMap(owner) {
8057
- var map = Private.ownerData.get(owner);
8058
- if (map) {
8059
- return map;
8060
- }
8061
- map = Object.create(null);
8062
- Private.ownerData.set(owner, map);
8063
- return map;
8064
- }
8065
- Private.ensureMap = ensureMap;
8066
- })(Private$m || (Private$m = {}));
8067
-
8068
8167
  /**
8069
8168
  * An object which manages a drag-drop operation.
8070
8169
  *
@@ -9371,7 +9470,10 @@
9371
9470
  }
9372
9471
  // Handle the simplest case of in-place text update first.
9373
9472
  if (oldVNode.type === 'text' && newVNode.type === 'text') {
9374
- currElem.textContent = newVNode.content;
9473
+ // Avoid spurious updates for performance.
9474
+ if (currElem.textContent !== newVNode.content) {
9475
+ currElem.textContent = newVNode.content;
9476
+ }
9375
9477
  currElem = currElem.nextSibling;
9376
9478
  continue;
9377
9479
  }
@@ -9677,15 +9779,15 @@
9677
9779
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9678
9780
  }
9679
9781
 
9680
- var __assign$1 = function() {
9681
- __assign$1 = Object.assign || function __assign(t) {
9782
+ var __assign$2 = function() {
9783
+ __assign$2 = Object.assign || function __assign(t) {
9682
9784
  for (var s, i = 1, n = arguments.length; i < n; i++) {
9683
9785
  s = arguments[i];
9684
9786
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9685
9787
  }
9686
9788
  return t;
9687
9789
  };
9688
- return __assign$1.apply(this, arguments);
9790
+ return __assign$2.apply(this, arguments);
9689
9791
  };
9690
9792
 
9691
9793
  function __rest(s, e) {
@@ -13322,7 +13424,7 @@
13322
13424
  * Titles must be rotated for horizontal accordion panel using CSS: see accordionpanel.css
13323
13425
  */
13324
13426
  function AccordionLayout(options) {
13325
- var _this = _super.call(this, __assign$1(__assign$1({}, options), { orientation: options.orientation || 'vertical' })) || this;
13427
+ var _this = _super.call(this, __assign$2(__assign$2({}, options), { orientation: options.orientation || 'vertical' })) || this;
13326
13428
  _this._titles = [];
13327
13429
  _this.titleSpace = options.titleSpace || 22;
13328
13430
  return _this;
@@ -13977,7 +14079,7 @@
13977
14079
  */
13978
14080
  function AccordionPanel(options) {
13979
14081
  if (options === void 0) { options = {}; }
13980
- var _this = _super.call(this, __assign$1(__assign$1({}, options), { layout: Private$d.createLayout(options) })) || this;
14082
+ var _this = _super.call(this, __assign$2(__assign$2({}, options), { layout: Private$d.createLayout(options) })) || this;
13981
14083
  _this._widgetSizesCache = new WeakMap();
13982
14084
  _this.addClass('lm-AccordionPanel');
13983
14085
  return _this;
@@ -15706,7 +15808,7 @@
15706
15808
  * @returns The dataset for the command palette item.
15707
15809
  */
15708
15810
  Renderer.prototype.createItemDataset = function (data) {
15709
- return __assign$1(__assign$1({}, data.item.dataset), { command: data.item.command });
15811
+ return __assign$2(__assign$2({}, data.item.dataset), { command: data.item.command });
15710
15812
  };
15711
15813
  /**
15712
15814
  * Create the class name for the command item icon.
@@ -15755,9 +15857,7 @@
15755
15857
  */
15756
15858
  Renderer.prototype.formatItemShortcut = function (data) {
15757
15859
  var kb = data.item.keyBinding;
15758
- return kb
15759
- ? kb.keys.map(exports.CommandRegistry.formatKeystroke).join(', ')
15760
- : null;
15860
+ return kb ? exports.CommandRegistry.formatKeystroke(kb.keys) : null;
15761
15861
  };
15762
15862
  /**
15763
15863
  * Create the render content for the item label node.
@@ -16958,6 +17058,8 @@
16958
17058
  if (submenu === this._childMenu) {
16959
17059
  return;
16960
17060
  }
17061
+ // Prior to any DOM modifications save window data
17062
+ Menu.saveWindowData();
16961
17063
  // Ensure the current child menu is closed.
16962
17064
  this._closeChildMenu();
16963
17065
  // Update the private child state.
@@ -17030,6 +17132,18 @@
17030
17132
  this._closeTimerID = 0;
17031
17133
  }
17032
17134
  };
17135
+ /**
17136
+ * Save window data used for menu positioning in transient cache.
17137
+ *
17138
+ * In order to avoid layout trashing it is recommended to invoke this
17139
+ * method immediately prior to opening the menu and any DOM modifications
17140
+ * (like closing previously visible menu, or adding a class to menu widget).
17141
+ *
17142
+ * The transient cache will be released upon `open()` call.
17143
+ */
17144
+ Menu.saveWindowData = function () {
17145
+ Private$9.saveWindowData();
17146
+ };
17033
17147
  return Menu;
17034
17148
  }(Widget));
17035
17149
  /**
@@ -17056,7 +17170,7 @@
17056
17170
  var className = this.createItemClass(data);
17057
17171
  var dataset = this.createItemDataset(data);
17058
17172
  var aria = this.createItemARIA(data);
17059
- return h.li(__assign$1({ className: className,
17173
+ return h.li(__assign$2({ className: className,
17060
17174
  dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data), this.renderShortcut(data), this.renderSubmenu(data));
17061
17175
  };
17062
17176
  /**
@@ -17186,10 +17300,10 @@
17186
17300
  var result;
17187
17301
  var _a = data.item, type = _a.type, command = _a.command, dataset = _a.dataset;
17188
17302
  if (type === 'command') {
17189
- result = __assign$1(__assign$1({}, dataset), { type: type, command: command });
17303
+ result = __assign$2(__assign$2({}, dataset), { type: type, command: command });
17190
17304
  }
17191
17305
  else {
17192
- result = __assign$1(__assign$1({}, dataset), { type: type });
17306
+ result = __assign$2(__assign$2({}, dataset), { type: type });
17193
17307
  }
17194
17308
  return result;
17195
17309
  };
@@ -17272,9 +17386,7 @@
17272
17386
  */
17273
17387
  Renderer.prototype.formatShortcut = function (data) {
17274
17388
  var kb = data.item.keyBinding;
17275
- return kb
17276
- ? kb.keys.map(exports.CommandRegistry.formatKeystroke).join(', ')
17277
- : null;
17389
+ return kb ? exports.CommandRegistry.formatKeystroke(kb.keys) : null;
17278
17390
  };
17279
17391
  return Renderer;
17280
17392
  }());
@@ -17297,6 +17409,30 @@
17297
17409
  * The horizontal pixel overlap for an open submenu.
17298
17410
  */
17299
17411
  Private.SUBMENU_OVERLAP = 3;
17412
+ var transientWindowDataCache = null;
17413
+ var transientCacheCounter = 0;
17414
+ function getWindowData() {
17415
+ // if transient cache is in use, take one from it
17416
+ if (transientCacheCounter > 0) {
17417
+ transientCacheCounter--;
17418
+ return transientWindowDataCache;
17419
+ }
17420
+ return _getWindowData();
17421
+ }
17422
+ /**
17423
+ * Store window data in transient cache.
17424
+ *
17425
+ * The transient cache will be released upon `getWindowData()` call.
17426
+ * If this function is called multiple times, the cache will be
17427
+ * retained until as many calls to `getWindowData()` were made.
17428
+ *
17429
+ * Note: should be called before any DOM modifications.
17430
+ */
17431
+ function saveWindowData() {
17432
+ transientWindowDataCache = _getWindowData();
17433
+ transientCacheCounter++;
17434
+ }
17435
+ Private.saveWindowData = saveWindowData;
17300
17436
  /**
17301
17437
  * Create the DOM node for a menu.
17302
17438
  */
@@ -17392,28 +17528,33 @@
17392
17528
  return result;
17393
17529
  }
17394
17530
  Private.computeCollapsed = computeCollapsed;
17531
+ function _getWindowData() {
17532
+ return {
17533
+ pageXOffset: window.pageXOffset,
17534
+ pageYOffset: window.pageYOffset,
17535
+ clientWidth: document.documentElement.clientWidth,
17536
+ clientHeight: document.documentElement.clientHeight
17537
+ };
17538
+ }
17395
17539
  /**
17396
17540
  * Open a menu as a root menu at the target location.
17397
17541
  */
17398
17542
  function openRootMenu(menu, x, y, forceX, forceY) {
17543
+ // Get the current position and size of the main viewport.
17544
+ var windowData = getWindowData();
17545
+ var px = windowData.pageXOffset;
17546
+ var py = windowData.pageYOffset;
17547
+ var cw = windowData.clientWidth;
17548
+ var ch = windowData.clientHeight;
17399
17549
  // Ensure the menu is updated before attaching and measuring.
17400
17550
  MessageLoop.sendMessage(menu, Widget.Msg.UpdateRequest);
17401
- // Get the current position and size of the main viewport.
17402
- var px = window.pageXOffset;
17403
- var py = window.pageYOffset;
17404
- var cw = document.documentElement.clientWidth;
17405
- var ch = document.documentElement.clientHeight;
17406
17551
  // Compute the maximum allowed height for the menu.
17407
17552
  var maxHeight = ch - (forceY ? y : 0);
17408
17553
  // Fetch common variables.
17409
17554
  var node = menu.node;
17410
17555
  var style = node.style;
17411
17556
  // Clear the menu geometry and prepare it for measuring.
17412
- style.top = '';
17413
- style.left = '';
17414
- style.width = '';
17415
- style.height = '';
17416
- style.visibility = 'hidden';
17557
+ style.opacity = '0';
17417
17558
  style.maxHeight = maxHeight + "px";
17418
17559
  // Attach the menu to the document.
17419
17560
  Widget.attach(menu, document.body);
@@ -17433,34 +17574,30 @@
17433
17574
  }
17434
17575
  }
17435
17576
  // Update the position of the menu to the computed position.
17436
- style.top = Math.max(0, y) + "px";
17437
- style.left = Math.max(0, x) + "px";
17577
+ style.transform = "translate(" + Math.max(0, x) + "px, " + Math.max(0, y) + "px";
17438
17578
  // Finally, make the menu visible on the screen.
17439
- style.visibility = '';
17579
+ style.opacity = '1';
17440
17580
  }
17441
17581
  Private.openRootMenu = openRootMenu;
17442
17582
  /**
17443
17583
  * Open a menu as a submenu using an item node for positioning.
17444
17584
  */
17445
17585
  function openSubmenu(submenu, itemNode) {
17586
+ // Get the current position and size of the main viewport.
17587
+ var windowData = getWindowData();
17588
+ var px = windowData.pageXOffset;
17589
+ var py = windowData.pageYOffset;
17590
+ var cw = windowData.clientWidth;
17591
+ var ch = windowData.clientHeight;
17446
17592
  // Ensure the menu is updated before opening.
17447
17593
  MessageLoop.sendMessage(submenu, Widget.Msg.UpdateRequest);
17448
- // Get the current position and size of the main viewport.
17449
- var px = window.pageXOffset;
17450
- var py = window.pageYOffset;
17451
- var cw = document.documentElement.clientWidth;
17452
- var ch = document.documentElement.clientHeight;
17453
17594
  // Compute the maximum allowed height for the menu.
17454
17595
  var maxHeight = ch;
17455
17596
  // Fetch common variables.
17456
17597
  var node = submenu.node;
17457
17598
  var style = node.style;
17458
17599
  // Clear the menu geometry and prepare it for measuring.
17459
- style.top = '';
17460
- style.left = '';
17461
- style.width = '';
17462
- style.height = '';
17463
- style.visibility = 'hidden';
17600
+ style.opacity = '0';
17464
17601
  style.maxHeight = maxHeight + "px";
17465
17602
  // Attach the menu to the document.
17466
17603
  Widget.attach(submenu, document.body);
@@ -17483,10 +17620,9 @@
17483
17620
  y = itemRect.bottom + box.borderBottom + box.paddingBottom - height;
17484
17621
  }
17485
17622
  // Update the position of the menu to the computed position.
17486
- style.top = Math.max(0, y) + "px";
17487
- style.left = Math.max(0, x) + "px";
17623
+ style.transform = "translate(" + Math.max(0, x) + "px, " + Math.max(0, y) + "px";
17488
17624
  // Finally, make the menu visible on the screen.
17489
- style.visibility = '';
17625
+ style.opacity = '1';
17490
17626
  }
17491
17627
  Private.openSubmenu = openSubmenu;
17492
17628
  /**
@@ -17810,6 +17946,8 @@
17810
17946
  */
17811
17947
  ContextMenu.prototype.open = function (event) {
17812
17948
  var _this = this;
17949
+ // Prior to any DOM modifications update the window data.
17950
+ Menu.saveWindowData();
17813
17951
  // Clear the current contents of the context menu.
17814
17952
  this.menu.clearItems();
17815
17953
  // Bail early if there are no items to match.
@@ -17844,7 +17982,7 @@
17844
17982
  function createItem(options, id) {
17845
17983
  var selector = validateSelector(options.selector);
17846
17984
  var rank = options.rank !== undefined ? options.rank : Infinity;
17847
- return __assign$1(__assign$1({}, options), { selector: selector, rank: rank, id: id });
17985
+ return __assign$2(__assign$2({}, options), { selector: selector, rank: rank, id: id });
17848
17986
  }
17849
17987
  Private.createItem = createItem;
17850
17988
  /**
@@ -19092,10 +19230,10 @@
19092
19230
  var dataset = this.createTabDataset(data);
19093
19231
  var aria = this.createTabARIA(data);
19094
19232
  if (data.title.closable) {
19095
- 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));
19233
+ 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));
19096
19234
  }
19097
19235
  else {
19098
- return h.li(__assign$1({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data));
19236
+ return h.li(__assign$2({ id: id, key: key, className: className, title: title, style: style, dataset: dataset }, aria), this.renderIcon(data), this.renderLabel(data));
19099
19237
  }
19100
19238
  };
19101
19239
  /**
@@ -23738,13 +23876,20 @@
23738
23876
  };
23739
23877
  /**
23740
23878
  * Handle the `'keydown'` event for the menu bar.
23879
+ *
23880
+ * #### Notes
23881
+ * All keys are trapped except the tab key that is ignored.
23741
23882
  */
23742
23883
  MenuBar.prototype._evtKeyDown = function (event) {
23743
- // A menu bar handles all keydown events.
23744
- event.preventDefault();
23745
- event.stopPropagation();
23746
23884
  // Fetch the key code for the event.
23747
23885
  var kc = event.keyCode;
23886
+ // Do not trap the tab key.
23887
+ if (kc === 9) {
23888
+ return;
23889
+ }
23890
+ // A menu bar handles all other keydown events.
23891
+ event.preventDefault();
23892
+ event.stopPropagation();
23748
23893
  // Enter, Up Arrow, Down Arrow
23749
23894
  if (kc === 13 || kc === 38 || kc === 40) {
23750
23895
  this.openActiveMenu();
@@ -23828,8 +23973,11 @@
23828
23973
  this.activeIndex = index;
23829
23974
  }
23830
23975
  else {
23976
+ var position = this._positionForMenu(index);
23977
+ Menu.saveWindowData();
23978
+ // Begin DOM modifications.
23831
23979
  this.activeIndex = index;
23832
- this._openChildMenu();
23980
+ this._openChildMenu(position);
23833
23981
  }
23834
23982
  };
23835
23983
  /**
@@ -23850,13 +23998,33 @@
23850
23998
  if (index === -1 && this._childMenu) {
23851
23999
  return;
23852
24000
  }
24001
+ // Get position for the new menu >before< updating active index.
24002
+ var position = this._positionForMenu(index);
24003
+ // Before any modification, update window data.
24004
+ Menu.saveWindowData();
24005
+ // Begin DOM modifications.
23853
24006
  // Update the active index to the hovered item.
23854
24007
  this.activeIndex = index;
23855
24008
  // Open the new menu if a menu is already open.
23856
24009
  if (this._childMenu) {
23857
- this._openChildMenu();
24010
+ this._openChildMenu(position);
23858
24011
  }
23859
24012
  };
24013
+ /**
24014
+ * Find initial position for the menu based on menubar item position.
24015
+ *
24016
+ * NOTE: this should be called before updating active index to avoid
24017
+ * an additional layout and style invalidation as changing active
24018
+ * index modifies DOM.
24019
+ */
24020
+ MenuBar.prototype._positionForMenu = function (index) {
24021
+ var itemNode = this.contentNode.children[index];
24022
+ var _a = itemNode.getBoundingClientRect(), left = _a.left, bottom = _a.bottom;
24023
+ return {
24024
+ top: bottom,
24025
+ left: left
24026
+ };
24027
+ };
23860
24028
  /**
23861
24029
  * Handle the `'mouseleave'` event for the menu bar.
23862
24030
  */
@@ -23872,7 +24040,9 @@
23872
24040
  * If a different child menu is already open, it will be closed,
23873
24041
  * even if there is no active menu.
23874
24042
  */
23875
- MenuBar.prototype._openChildMenu = function () {
24043
+ MenuBar.prototype._openChildMenu = function (options) {
24044
+ var _a;
24045
+ if (options === void 0) { options = {}; }
23876
24046
  // If there is no active menu, close the current menu.
23877
24047
  var newMenu = this.activeMenu;
23878
24048
  if (!newMenu) {
@@ -23891,20 +24061,26 @@
23891
24061
  oldMenu.close();
23892
24062
  }
23893
24063
  else {
23894
- this.addClass('lm-mod-active');
23895
- /* <DEPRECATED> */
23896
- this.addClass('p-mod-active');
23897
- /* </DEPRECATED> */
23898
24064
  document.addEventListener('mousedown', this, true);
23899
24065
  }
23900
24066
  // Ensure the menu bar is updated and look up the item node.
23901
24067
  MessageLoop.sendMessage(this, Widget.Msg.UpdateRequest);
23902
- var itemNode = this.contentNode.children[this._activeIndex];
23903
24068
  // Get the positioning data for the new menu.
23904
- var _a = itemNode.getBoundingClientRect(), left = _a.left, bottom = _a.bottom;
24069
+ var left = options.left, top = options.top;
24070
+ if (typeof left === 'undefined' || typeof top === 'undefined') {
24071
+ (_a = this._positionForMenu(this._activeIndex), left = _a.left, top = _a.top);
24072
+ }
24073
+ // Begin DOM modifications
24074
+ if (!oldMenu) {
24075
+ // Continue setup for new menu
24076
+ this.addClass('lm-mod-active');
24077
+ /* <DEPRECATED> */
24078
+ this.addClass('p-mod-active');
24079
+ /* </DEPRECATED> */
24080
+ }
23905
24081
  // Open the new menu at the computed location.
23906
24082
  if (newMenu.items.length > 0) {
23907
- newMenu.open(left, bottom, this._forceItemsPosition);
24083
+ newMenu.open(left, top, this._forceItemsPosition);
23908
24084
  }
23909
24085
  };
23910
24086
  /**
@@ -24007,7 +24183,7 @@
24007
24183
  var className = this.createItemClass(data);
24008
24184
  var dataset = this.createItemDataset(data);
24009
24185
  var aria = this.createItemARIA(data);
24010
- return h.li(__assign$1({ className: className, dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data));
24186
+ return h.li(__assign$2({ className: className, dataset: dataset, tabindex: '0', onfocus: data.onfocus }, aria), this.renderIcon(data), this.renderLabel(data));
24011
24187
  };
24012
24188
  /**
24013
24189
  * Render the icon element for a menu bar item.