bm-core-ui 2.7.0 → 2.8.3

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.
@@ -6,9 +6,9 @@ import {BMRectMake, BMRectMakeWithNodeFrame} from '../Core/BMRect'
6
6
  import {BMAnimateWithBlock, BMAnimationContextGetCurrent, BMAnimationContextEnableWebAnimations, __BMVelocityAnimate, BMHook} from '../Core/BMAnimationContext'
7
7
  import {BMView} from '../BMView/BMView_v2.5'
8
8
  import {BMLayoutOrientation} from '../BMView/BMLayoutSizeClass'
9
- import { BMKeyboardShortcutModifier } from './BMKeyboardShortcut'
10
9
  import { BMSizeMake } from '../Core/BMSize'
11
10
  import { BMLayoutAttribute } from '../BMView/BMLayoutConstraint_v2.5'
11
+ import { BMViewport } from '../BMView/BMViewport'
12
12
 
13
13
  //@ts-check
14
14
  // @type BMWindowOverlay extends BMView
@@ -682,11 +682,6 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
682
682
  * An array containing the tool windows associated with this window.
683
683
  */
684
684
  _toolWindows: undefined, // <[BMToolWindow]>
685
-
686
- /**
687
- * The keyboard shortcuts that have been registered to this window.
688
- */
689
- _keyboardShortcuts: undefined, // <[BMKeyboardShortcut]>
690
685
 
691
686
  /**
692
687
  * Initializes this window with the given screen area.
@@ -704,7 +699,6 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
704
699
  let modal = (args && 'modal' in args) ? args.modal : YES;
705
700
 
706
701
  this._toolWindows = [];
707
- this._keyboardShortcuts = [];
708
702
 
709
703
  this._overlay = (new BMWindowOverlay).initWithWindow(this, {modal});
710
704
  this._blocker = this._overlay.node;
@@ -1067,91 +1061,22 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1067
1061
  if (this._fullScreen) this.layout();
1068
1062
  },
1069
1063
 
1070
- /**
1071
- * Registers a keyboard shortcut that can be activated when this window is the key window.
1072
- * @param shortcut <BMKeyboardShortcut> The keyboard shortcut to register.
1073
- */
1074
- registerKeyboardShortcut(shortcut) {
1075
- if (!this._keyboardShortcuts.length) this._enableKeyboardShortcuts();
1076
-
1077
- this._keyboardShortcuts.push(shortcut);
1078
- },
1079
-
1080
- /**
1081
- * Unregisters a keyboard shortcut. If this keyboard shortcut had not been previously registered, this method does nothing.
1082
- * @param shortcut <BMKeyboardShortcut> The keyboard shortcut to unregister.
1083
- */
1084
- unregisterKeyboardShortcut(shortcut) {
1085
- for (let i = 0; i < this._keyboardShortcuts.length; i++) {
1086
- if (this._keyboardShortcuts[i] == shortcut) {
1087
- this._keyboardShortcuts.splice(i, 1);
1088
- break;
1089
- }
1090
- }
1091
-
1092
- if (!this._keyboardShortcuts.length) this._disableKeyboardShortcuts();
1093
- },
1094
-
1095
- /**
1096
- * If keyboard shortcuts have been registered on this window, this method will be invoked to identify
1097
- * and handle key presses. Subclasses that override this method should invoke the base implementation to allow
1098
- * keyboard shortcuts to be handled correctly.
1099
- * @param event <KeyboardEvent> The event that triggered this action.
1100
- */
1101
- keyPressedWithEvent(event) {
1102
- // Check if a shortcut key has been pressed.
1103
- for (const shortcut of this._keyboardShortcuts) {
1104
- if (event.code != shortcut.keyCode) continue;
1105
-
1106
- // Build the modifier bitmap for this event
1107
- let bitmap = 0;
1108
- for (const modifier in BMKeyboardShortcutModifier) {
1109
- if (event[BMKeyboardShortcutModifier[modifier].key]) {
1110
- bitmap = bitmap | BMKeyboardShortcutModifier[modifier].value;
1111
- }
1112
- }
1113
-
1114
- if (bitmap == shortcut._modifierBitmap) {
1115
- if (shortcut.preventsDefault) event.preventDefault();
1116
- shortcut.target[shortcut.action](event);
1117
- }
1118
- }
1119
- },
1120
-
1121
- /**
1122
- * Set to `YES` if keyboard shortcuts are enabled.
1123
- */
1124
- _keyboardShortcutsEnabled: NO, // <Boolean>
1125
-
1126
1064
  /**
1127
1065
  * Enables keyboard shortcut handling. This makes the window's `node` focusable and attaches
1128
1066
  * the relevant event handlers to it. If this window is the key window and the keyboard focus
1129
1067
  * is outside of this window, this window will acquire keyboard focus.
1130
1068
  */
1131
1069
  _enableKeyboardShortcuts() {
1132
- this.node.tabIndex = -1;
1070
+ BMView.prototype._enableKeyboardShortcuts.apply(this, arguments);
1133
1071
 
1134
- if (document.activeElement && !this.node.contains(document.activeElement)) {
1135
- this.node.focus();
1136
- }
1137
- else if (!document.activeElement) {
1138
- this.node.focus();
1072
+ if (this.isModal || this.isKeyWindow) {
1073
+ if (document.activeElement && !this.node.contains(document.activeElement)) {
1074
+ this.node.focus();
1075
+ }
1076
+ else if (!document.activeElement) {
1077
+ this.node.focus();
1078
+ }
1139
1079
  }
1140
-
1141
- this._keypressHandler = (event) => {
1142
- this.keyPressedWithEvent(event);
1143
- };
1144
-
1145
- this.node.addEventListener('keydown', this._keypressHandler);
1146
- this._keyboardShortcutsEnabled = YES;
1147
- },
1148
-
1149
- /**
1150
- * Disables keyboard shortcut handling. This detaches the relevant event handlers from this window's `node`.
1151
- */
1152
- _disableKeyboardShortcuts() {
1153
- this.node.removeEventListener('keydown', this._keypressHandler);
1154
- this._keyboardShortcutsEnabled = NO;
1155
1080
  },
1156
1081
 
1157
1082
  /**
@@ -1199,6 +1124,7 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1199
1124
  const animationNode = node.cloneNode(YES);
1200
1125
 
1201
1126
  const nodeDisplay = node.style.display;
1127
+ self._nodeDisplay = nodeDisplay;
1202
1128
 
1203
1129
  animationNode.style.position = 'fixed';
1204
1130
  animationNode.style.zIndex = BM_WINDOW_Z_INDEX_MAX + 1;
@@ -1240,6 +1166,7 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1240
1166
  }
1241
1167
  else {
1242
1168
  node.style.display = nodeDisplay;
1169
+ self._nodeDisplay = undefined;
1243
1170
  }
1244
1171
 
1245
1172
  completionHandler();
@@ -1329,6 +1256,10 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1329
1256
  completionHandler = () => {
1330
1257
  this.anchorRect = undefined;
1331
1258
  this.anchorNode = undefined;
1259
+
1260
+ if (this._keyboardShortcutsEnabled) {
1261
+ this.node.focus();
1262
+ }
1332
1263
  }
1333
1264
  }
1334
1265
 
@@ -1337,6 +1268,10 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1337
1268
  this._blocker.style.display = 'block';
1338
1269
  this._window.style.display = 'block';
1339
1270
 
1271
+ if (this._keyboardShortcutsEnabled) {
1272
+ this.node.focus();
1273
+ }
1274
+
1340
1275
  this._overlay._windowWillAppear();
1341
1276
 
1342
1277
  }
@@ -1352,15 +1287,15 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1352
1287
 
1353
1288
  this._blocker.style.pointerEvents = '';
1354
1289
  this._window.style.pointerEvents = '';
1290
+
1291
+ if (this._keyboardShortcutsEnabled) {
1292
+ this.node.focus();
1293
+ }
1355
1294
 
1356
1295
  if (self.delegate && self.delegate.windowDidAppear) self.delegate.windowDidAppear(self);
1357
1296
 
1358
1297
  if (args && args.completionHandler) args.completionHandler();
1359
1298
  }
1360
-
1361
- if (this._keyboardShortcutsEnabled) {
1362
- this.node.focus();
1363
- }
1364
1299
  },
1365
1300
 
1366
1301
 
@@ -1393,14 +1328,14 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1393
1328
  // Create a copy of the given node which will be used in the animation in place of the original node
1394
1329
  const node = this._anchorNode;
1395
1330
 
1396
- if ('_nodeDisplay' in self) {
1331
+ if (typeof self._nodeDisplay != 'undefined') {
1397
1332
  node.style.display = self._nodeDisplay;
1398
1333
  }
1399
1334
 
1400
1335
  const rect = BMRectMakeWithNodeFrame(node);
1401
1336
  const animationNode = node.cloneNode(YES);
1402
1337
 
1403
- const nodeDisplay = ('_nodeDisplay' in self) ? self._nodeDisplay : node.style.display;
1338
+ const nodeDisplay = (typeof self._nodeDisplay != 'undefined') ? self._nodeDisplay : node.style.display;
1404
1339
  self._nodeDisplay = undefined;
1405
1340
 
1406
1341
  animationNode.style.position = 'fixed';
@@ -834,10 +834,6 @@ export function BMAnimationApplyBlocking(blocking) {
834
834
  }
835
835
  animation.options.complete = completeCallback;
836
836
 
837
- if (window.event && window.event.shiftKey) {
838
- animation.options.duration = animation.options.duration * 5;
839
- window.event.preventDefault();
840
- }
841
837
 
842
838
  var stride = animation.options.stride;
843
839
  var delay = animation.options.delay || 0;
@@ -391,6 +391,10 @@ export function BMUUIDMake() {
391
391
  * An enum containing HTML entities for various commonly used symbols.
392
392
  */
393
393
  export var BMHTMLEntity = Object.freeze({ // <enum>
394
+ /**
395
+ * The HTML entity representing the control key.
396
+ */
397
+ Control: '&#8963;', // <enum>
394
398
  /**
395
399
  * The HTML entity representing the bowen knot Command symbol.
396
400
  */
@@ -414,7 +418,11 @@ export var BMHTMLEntity = Object.freeze({ // <enum>
414
418
  /**
415
419
  * The HTML entity representing the Return symbol.
416
420
  */
417
- Return: '&#9166;' // <enum>
421
+ Return: '&#9166;', // <enum>
422
+ /**
423
+ * The HTML entity representing the Escape symbol.
424
+ */
425
+ Escape: '&#9099;', // <enum>
418
426
  });
419
427
 
420
428
  // @endtype