bm-core-ui 2.11.0 → 2.11.2

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.
@@ -13920,6 +13920,51 @@ export class BMWindow extends BMView {
13920
13920
  initWithFrame(frame: BMRect, {toolbar, modal}?: {toolbar?: boolean | null | undefined, modal?: boolean | null | undefined}): BMWindow;
13921
13921
 
13922
13922
 
13923
+ /**
13924
+ * Starts a drag event from the specified `mousedown` or `touchstart` event that moves this window.
13925
+ * When this method is invoked, further mouse and touch events will be blocked until the drag finishes.
13926
+ *
13927
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
13928
+ * this method has no effect.
13929
+ * @param event The `mousedown` or `touchstart` event from which to begin
13930
+ * the window movement.
13931
+ *
13932
+ */
13933
+ performDragWithEvent(event: MouseEvent | TouchEvent): void;
13934
+
13935
+
13936
+ /**
13937
+ * Starts a drag event from the specified `mousedown` event that will move this window.
13938
+ * When this method is invoked, further mouse events will be blocked until the drag finishes.
13939
+ *
13940
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
13941
+ * this method has no effect.
13942
+ * @param event The `mousedown` event from which to begin the window movement.
13943
+ *
13944
+ */
13945
+ performDragWithMouseEvent(event: MouseEvent | TouchEvent): void;
13946
+
13947
+
13948
+ /**
13949
+ * The identifier of the touch point that is tracked during a drag operation. `undefined`
13950
+ * when not tracking a drag.
13951
+ *
13952
+ */
13953
+ private _touchDragPoint: string;
13954
+
13955
+ /**
13956
+ * Starts a drag event from the specified `touchstart` event that will move this window.
13957
+ * When this method is invoked, further touch events will be blocked until the drag finishes.
13958
+ *
13959
+ *
13960
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
13961
+ * this method has no effect.
13962
+ * @param event The `touchstart` event from which to begin the window movement.
13963
+ *
13964
+ */
13965
+ performDragWithTouchEvent(event: MouseEvent | TouchEvent): void;
13966
+
13967
+
13923
13968
  /**
13924
13969
  * Invoked on non-modal windows when the viewport resizes.
13925
13970
  * @param event The event that triggered this action.
@@ -4594,7 +4594,7 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
4594
4594
  * }
4595
4595
  */
4596
4596
  setLayout: function (layout, options) {
4597
- // If there is an in-progress animated update, schedule this call for later
4597
+ // If there is an in-progress animated update, schedule this call for when that update finishes
4598
4598
  if (this.isUpdatingData) {
4599
4599
  var self = this;
4600
4600
  this.registerDataCompletionCallback(function () {
@@ -4625,7 +4625,8 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
4625
4625
  BMAnimationContextBeginStatic();
4626
4626
 
4627
4627
  let resolveLayoutUpdate;
4628
- this._dataUpdatePromise = new Promise($1 => resolveLayoutUpdate = $1);
4628
+ const dataUpdatePromise = new Promise($1 => resolveLayoutUpdate = $1);
4629
+ this._dataUpdatePromise = dataUpdatePromise;
4629
4630
 
4630
4631
  // Discard the cached attribute pages
4631
4632
  this.attributeCache = {};
@@ -4916,16 +4917,19 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
4916
4917
 
4917
4918
  self._applyOverflows();
4918
4919
 
4919
- self._collectionEnabled = YES;
4920
- self.isUpdatingData = NO;
4920
+ // Restore collection invoke the data completion callbacks unless another animation is in progress
4921
+ if (self._dataUpdatePromise == dataUpdatePromise) {
4922
+ self._collectionEnabled = YES;
4923
+ self.isUpdatingData = NO;
4924
+
4925
+ self._executeDataCompletionCallbacks();
4926
+ }
4927
+
4928
+ // If the delegate animation options contains a complete handler, invoke it here
4929
+ if (delegateOptions.complete) delegateOptions.complete();
4921
4930
 
4922
- self._executeDataCompletionCallbacks();
4923
-
4924
- // If the delegate animation options contains a complete handler, invoke it here
4925
- if (delegateOptions.complete) delegateOptions.complete();
4926
-
4927
- // Run the completion handler if it was specified
4928
- if (options && options.completionHandler) options.completionHandler();
4931
+ // Run the completion handler if it was specified
4932
+ if (options && options.completionHandler) options.completionHandler();
4929
4933
 
4930
4934
  resolveLayoutUpdate();
4931
4935
  };
@@ -5152,7 +5156,8 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
5152
5156
  var self = this;
5153
5157
 
5154
5158
  let resolveUpdateData;
5155
- this._dataUpdatePromise = new Promise(function (resolve, reject) {resolveUpdateData = resolve});
5159
+ const dataUpdatePromise = new Promise(function (resolve, reject) {resolveUpdateData = resolve});
5160
+ this._dataUpdatePromise = dataUpdatePromise;
5156
5161
 
5157
5162
  // Update the selection index paths
5158
5163
  this._updateSelectionIndexPaths();
@@ -5567,11 +5572,10 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
5567
5572
  }
5568
5573
  animationComplete = YES;
5569
5574
 
5570
- // Apply the new size now if it wasn't already applied earlier
5571
- if (!contentSizeWidthApplied) {
5575
+ // Apply the new size now, unless another animation is in progress
5576
+ if (self._dataUpdatePromise == dataUpdatePromise) {
5577
+ const contentSize = self.layout.contentSize();
5572
5578
  self._contentWrapper.css({width: contentSize.width + 'px'});
5573
- }
5574
- if (!contentSizeHeightApplied) {
5575
5579
  self._contentWrapper.css({height: contentSize.height + 'px'});
5576
5580
  }
5577
5581
 
@@ -5596,17 +5600,21 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
5596
5600
  deletedCells[i].recycle();
5597
5601
  }
5598
5602
 
5599
- self._applyOverflows();
5600
- self._container[0].style.pointerEvents = 'inherit';//.css({'pointer-events': 'inherit'});
5603
+ // If another update is not in progress, re-enable scrolling and collection
5604
+ if (self._dataUpdatePromise == dataUpdatePromise) {
5605
+ self._applyOverflows();
5606
+ self._container[0].style.pointerEvents = 'inherit';//.css({'pointer-events': 'inherit'});
5607
+
5608
+ if (self.scrollView) self.scrollView.scrollingEnabled = YES;
5601
5609
 
5602
- if (self.scrollView) self.scrollView.scrollingEnabled = YES;
5603
-
5604
- self._collectionEnabled = YES;
5605
-
5606
- // Set the updating flag back to NO
5607
- self.isUpdatingData = NO;
5610
+ self._collectionEnabled = YES;
5608
5611
 
5609
- self._executeDataCompletionCallbacks();
5612
+ // Set the updating flag back to NO
5613
+ self.isUpdatingData = NO;
5614
+
5615
+ // Only execute data completion callbacks after all pending updates have finished
5616
+ self._executeDataCompletionCallbacks();
5617
+ }
5610
5618
 
5611
5619
  if (options && options.completionHandler) options.completionHandler();
5612
5620
  if (delegateOptions.complete) delegateOptions.complete.apply(this, arguments);
@@ -192,7 +192,7 @@
192
192
  background: rgba(245, 245, 245, .8);
193
193
  }
194
194
 
195
- .BMWindow.BMKeyWindow::before, .BMToolWindow::before {
195
+ .BMWindow.BMKeyWindow, .BMToolWindow {
196
196
  backdrop-filter: blur(15px);
197
197
  -webkit-backdrop-filter: blur(15px);
198
198
  }
@@ -1169,6 +1169,9 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
1169
1169
  color: rgba(0, 0, 0, .8);
1170
1170
 
1171
1171
  border-radius: 8px;
1172
+
1173
+ backdrop-filter: blur(25px);
1174
+ -webkit-backdrop-filter: blur(25px);
1172
1175
  }
1173
1176
 
1174
1177
  .BMLayoutEditorConstraintPopup::before, .BMMenu::before {
@@ -1181,11 +1184,6 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
1181
1184
  bottom: 0;
1182
1185
 
1183
1186
  border-radius: 8px;
1184
-
1185
- backdrop-filter: blur(25px);
1186
- -webkit-backdrop-filter: blur(25px);
1187
-
1188
- z-index: -1;
1189
1187
  }
1190
1188
 
1191
1189
  .BMMenuSourceNodeShadow {
@@ -1332,6 +1330,10 @@ input:not(:checked) + .BMWindowSwitchGutter > .BMWindowSwitchKnob, .BMWindowSwit
1332
1330
  /* The menu's text element should expand to fill all available space */
1333
1331
  .BMMenuItem > span {
1334
1332
  flex-grow: 1;
1333
+
1334
+ overflow: hidden;
1335
+ text-overflow: ellipsis;
1336
+ white-space: nowrap;
1335
1337
  }
1336
1338
 
1337
1339
  .BMMenuItemHint {
@@ -995,20 +995,37 @@ BMMenu.prototype = {
995
995
  // that the first menu item appears directly on the pointer's position
996
996
  const point = BMPointMake(rect.right, rect.origin.y - paddingTop);
997
997
 
998
+ const windowWidth = window.innerWidth;
999
+ const windowHeight = window.innerHeight;
1000
+
998
1001
  // Determine where to place the menu based on where it fits best, preferring towards
999
1002
  // the bottom-right of the origin point
1000
1003
  if (kind == BMMenuKind.PullDownMenu) {
1001
1004
  transformOriginX = '50%';
1002
1005
  }
1003
- else if (width + point.x > document.documentElement.clientWidth) {
1004
- // If the menu doesn't fit towards the right, open it towards the left
1005
- transformOriginX = '100%';
1006
- point.x = rect.origin.x - width;
1006
+ else if (width + point.x > windowWidth) {
1007
+ // If the menu doesn't fit towards the right, open it towards the left, if it has more space
1008
+ if (point.x > windowWidth / 2) {
1009
+ transformOriginX = '100%';
1010
+ point.x = rect.origin.x - width;
1011
+
1012
+ menuNode.style.maxWidth = point.x + 'px'
1013
+ }
1014
+ else {
1015
+ menuNode.style.maxWidth = (window.innerWidth - point.x) + 'px';
1016
+ }
1007
1017
  }
1008
- if (height + point.y > document.documentElement.clientHeight) {
1009
- // If the menu doesn't fit towards the bottom, open it towards the top
1010
- transformOriginY = ' 100%';
1011
- point.y = rect.bottom + paddingBottom - height;
1018
+ if (height + point.y > windowHeight) {
1019
+ // If the menu doesn't fit towards the bottom, open it towards the top, if it has more space
1020
+ if (point.y > windowHeight / 2) {
1021
+ transformOriginY = ' 100%';
1022
+ point.y = Math.max(rect.bottom + paddingBottom - height, 0);
1023
+
1024
+ menuNode.style.maxHeight = point.y + 'px';
1025
+ }
1026
+ else {
1027
+ menuNode.style.maxHeight = (windowHeight - point.y) + 'px';
1028
+ }
1012
1029
  }
1013
1030
  menuNode.style.transformOrigin = transformOriginX + transformOriginY;
1014
1031
 
@@ -1075,6 +1075,147 @@ BMWindow.prototype = BMExtend(Object.create(BMView.prototype), {
1075
1075
  return this;
1076
1076
  },
1077
1077
 
1078
+ /**
1079
+ * Starts a drag event from the specified `mousedown` or `touchstart` event that moves this window.
1080
+ * When this method is invoked, further mouse and touch events will be blocked until the drag finishes.
1081
+ *
1082
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
1083
+ * this method has no effect.
1084
+ * @param event <MouseEvent | TouchEvent> The `mousedown` or `touchstart` event from which to begin
1085
+ * the window movement.
1086
+ */
1087
+ performDragWithEvent(event) {
1088
+ if (event.type == 'mousedown') {
1089
+ this.performDragWithMouseEvent(event);
1090
+ }
1091
+ else if (event.type == 'touchstart') {
1092
+ this.performDragWithTouchEvent(event);
1093
+ }
1094
+ },
1095
+
1096
+ /**
1097
+ * Starts a drag event from the specified `mousedown` event that will move this window.
1098
+ * When this method is invoked, further mouse events will be blocked until the drag finishes.
1099
+ *
1100
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
1101
+ * this method has no effect.
1102
+ * @param event <MouseEvent | TouchEvent> The `mousedown` event from which to begin the window movement.
1103
+ */
1104
+ performDragWithMouseEvent(event) {
1105
+ // Full screen and modal windows cannot be moved
1106
+ if (this._fullScreen) return;
1107
+
1108
+ this._dragged = YES;
1109
+
1110
+ this._position = BMPointMake(this.node.offsetLeft, this.node.offsetTop);
1111
+ let lastPosition = BMPointMake(event.clientX, event.clientY);
1112
+
1113
+ let mouseMoveEventListener = event => {
1114
+ let position = BMPointMake(event.clientX, event.clientY);
1115
+ const newPosition = BMPointMake(this._position.x + position.x - lastPosition.x, this._position.y + position.y - lastPosition.y);
1116
+
1117
+ // Check if the window can move
1118
+ let canMove = YES;
1119
+ if (this.delegate && this.delegate.windowShouldMove) {
1120
+ canMove = this.delegate.windowShouldMove(this, newPosition);
1121
+ }
1122
+ if (!canMove) return;
1123
+
1124
+ this.leftConstraint.constant = this._position.x + position.x - lastPosition.x;
1125
+ this.topConstraint.constant = this._position.y + position.y - lastPosition.y;
1126
+ this._position = newPosition;
1127
+ lastPosition = position;
1128
+ this.layout();
1129
+ event.preventDefault();
1130
+ };
1131
+
1132
+ let mouseUpEventListener = event => {
1133
+ window.removeEventListener('mousemove', mouseMoveEventListener, YES);
1134
+ window.removeEventListener('mouseup', mouseUpEventListener, YES);
1135
+ }
1136
+
1137
+ window.addEventListener('mousemove', mouseMoveEventListener, YES);
1138
+ window.addEventListener('mouseup', mouseUpEventListener, YES);
1139
+
1140
+ event.preventDefault();
1141
+ },
1142
+
1143
+ /**
1144
+ * The identifier of the touch point that is tracked during a drag operation. `undefined`
1145
+ * when not tracking a drag.
1146
+ */
1147
+ _touchDragPoint: undefined, // <String>
1148
+
1149
+ /**
1150
+ * Starts a drag event from the specified `touchstart` event that will move this window.
1151
+ * When this method is invoked, further touch events will be blocked until the drag finishes.
1152
+ *
1153
+ *
1154
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
1155
+ * this method has no effect.
1156
+ * @param event <MouseEvent | TouchEvent> The `touchstart` event from which to begin the window movement.
1157
+ */
1158
+ performDragWithTouchEvent(event) {
1159
+ // If there is already a drag in progress, don't process this new event
1160
+ if (typeof this._touchDragPoint !== 'undefined') {
1161
+ return;
1162
+ }
1163
+
1164
+ // Full screen windows cannot be moved
1165
+ if (this._fullScreen) return;
1166
+
1167
+ // Only use the first touch point
1168
+ this._touchDragPoint = event.changedTouches[0].identifier;
1169
+ this._dragged = YES;
1170
+
1171
+ this._position = BMPointMake(this.node.offsetLeft, this.node.offsetTop);
1172
+ let lastPosition = BMPointMake(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
1173
+
1174
+ let mouseMoveEventListener = event => {
1175
+ // Look for the actively tracked touch point
1176
+ let touch;
1177
+ for (let changedTouch of event.changedTouches) {
1178
+ if (changedTouch.identifier == this._touchDragPoint) {
1179
+ touch = changedTouch;
1180
+ break;
1181
+ }
1182
+ }
1183
+
1184
+ // If the actively tracked touch point did not move, do not process this event
1185
+ if (!touch) return;
1186
+
1187
+ let position = BMPointMake(touch.clientX, touch.clientY);
1188
+ const newPosition = BMPointMake(this._position.x + position.x - lastPosition.x, this._position.y + position.y - lastPosition.y);
1189
+
1190
+ // Check if the window can move
1191
+ let canMove = YES;
1192
+ if (this.delegate && this.delegate.windowShouldMove) {
1193
+ canMove = this.delegate.windowShouldMove(this, newPosition);
1194
+ }
1195
+ if (!canMove) return;
1196
+
1197
+ this.leftConstraint.constant = this._position.x + position.x - lastPosition.x;
1198
+ this.topConstraint.constant = this._position.y + position.y - lastPosition.y;
1199
+ this._position = newPosition;
1200
+ lastPosition = position;
1201
+ this.layout();
1202
+ event.preventDefault();
1203
+ };
1204
+
1205
+ let mouseUpEventListener = event => {
1206
+ this._touchDragPoint = undefined;
1207
+ window.removeEventListener('touchmove', mouseMoveEventListener);
1208
+ window.removeEventListener('touchend', mouseUpEventListener);
1209
+ window.removeEventListener('touchcancel', mouseUpEventListener);
1210
+ }
1211
+
1212
+ window.addEventListener('touchmove', mouseMoveEventListener);
1213
+ window.addEventListener('touchend', mouseUpEventListener);
1214
+ window.removeEventListener('touchcancel', mouseUpEventListener);
1215
+
1216
+ event.preventDefault();
1217
+ },
1218
+
1078
1219
  // @override - BMView
1079
1220
  colorSchemeDidChange(scheme) {
1080
1221
  BMView.prototype.colorSchemeDidChange.apply(this, arguments);
@@ -499,7 +499,7 @@ export function __BMVelocityAnimate(node, properties, options, useWebAnimations)
499
499
  export function BMHook(element, properties) {
500
500
  if (BM_USE_VELOCITY2) {
501
501
  let node = element;
502
- if (element instanceof window.$) {
502
+ if (window.$ && element instanceof window.$) {
503
503
  node = element[0];
504
504
  }
505
505
 
@@ -969,7 +969,7 @@ export function BMAnimationApplyBlocking(blocking) {
969
969
 
970
970
  // Set up the animation
971
971
  let node = element;
972
- if (element instanceof window.$) {
972
+ if (window.$ && element instanceof window.$) {
973
973
  node = element[0];
974
974
  }
975
975
 
@@ -1071,7 +1071,7 @@ export function BMAnimationApplyBlocking(blocking) {
1071
1071
 
1072
1072
  }
1073
1073
  else if (BM_USE_VELOCITY2) {
1074
- if (element instanceof window.$) {
1074
+ if (window.$ && element instanceof window.$) {
1075
1075
  promises.push(element[0].velocity(animationTargets[i].properties, options));
1076
1076
  }
1077
1077
  else {
@@ -1091,6 +1091,11 @@ export function BMAnimationApplyBlocking(blocking) {
1091
1091
  const properties = animationTargets[i].properties;
1092
1092
  const animationOptions = options;
1093
1093
 
1094
+ // If there are no properties specified for this element, add a dummy tween property
1095
+ if (!Object.keys(properties).length) {
1096
+ properties.tween = [1, 0];
1097
+ }
1098
+
1094
1099
  promises.push(new Promise(async resolve => {
1095
1100
  const delay = options.delay;
1096
1101
  options.delay = undefined;
@@ -1122,6 +1127,11 @@ export function BMAnimationApplyBlocking(blocking) {
1122
1127
  }));
1123
1128
  }
1124
1129
  else {
1130
+ // If there are no properties specified for this element, add a dummy tween property
1131
+ if (!Object.keys(animationTargets[i].properties).length) {
1132
+ animationTargets[i].properties.tween = [1, 0];
1133
+ }
1134
+
1125
1135
  promises.push(velocity.animate(element, animationTargets[i].properties, options));
1126
1136
  }
1127
1137
  }
@@ -13920,6 +13920,51 @@ declare class BMWindow extends BMView {
13920
13920
  initWithFrame(frame: BMRect, {toolbar, modal}?: {toolbar?: boolean | null | undefined, modal?: boolean | null | undefined}): BMWindow;
13921
13921
 
13922
13922
 
13923
+ /**
13924
+ * Starts a drag event from the specified `mousedown` or `touchstart` event that moves this window.
13925
+ * When this method is invoked, further mouse and touch events will be blocked until the drag finishes.
13926
+ *
13927
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
13928
+ * this method has no effect.
13929
+ * @param event The `mousedown` or `touchstart` event from which to begin
13930
+ * the window movement.
13931
+ *
13932
+ */
13933
+ performDragWithEvent(event: MouseEvent | TouchEvent): void;
13934
+
13935
+
13936
+ /**
13937
+ * Starts a drag event from the specified `mousedown` event that will move this window.
13938
+ * When this method is invoked, further mouse events will be blocked until the drag finishes.
13939
+ *
13940
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
13941
+ * this method has no effect.
13942
+ * @param event The `mousedown` event from which to begin the window movement.
13943
+ *
13944
+ */
13945
+ performDragWithMouseEvent(event: MouseEvent | TouchEvent): void;
13946
+
13947
+
13948
+ /**
13949
+ * The identifier of the touch point that is tracked during a drag operation. `undefined`
13950
+ * when not tracking a drag.
13951
+ *
13952
+ */
13953
+ private _touchDragPoint: string;
13954
+
13955
+ /**
13956
+ * Starts a drag event from the specified `touchstart` event that will move this window.
13957
+ * When this method is invoked, further touch events will be blocked until the drag finishes.
13958
+ *
13959
+ *
13960
+ * If there is already a drag operation in progress or if this window is full screen or a modal window,
13961
+ * this method has no effect.
13962
+ * @param event The `touchstart` event from which to begin the window movement.
13963
+ *
13964
+ */
13965
+ performDragWithTouchEvent(event: MouseEvent | TouchEvent): void;
13966
+
13967
+
13923
13968
  /**
13924
13969
  * Invoked on non-modal windows when the viewport resizes.
13925
13970
  * @param event The event that triggered this action.