bm-core-ui 2.12.0-beta.10 → 2.12.0-beta.13

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.
@@ -5838,6 +5838,12 @@ export class BMDragSession implements EventHandlerObject {
5838
5838
  */
5839
5839
  readonly transferKind?: BMDragTransferKind | null | undefined;
5840
5840
 
5841
+ /**
5842
+ * Set to `YES` after this drag session finishes.
5843
+ *
5844
+ */
5845
+ private _finished: boolean;
5846
+
5841
5847
  /**
5842
5848
  * Sets up the drag previews and indicator and appropriate event handlers and starts tracking
5843
5849
  * a drag originating from the event with which this drag session was initialized.
@@ -5902,6 +5908,22 @@ export class BMDragSession implements EventHandlerObject {
5902
5908
  private _setDropTarget(target?: BMView | null | undefined): void;
5903
5909
 
5904
5910
 
5911
+ /**
5912
+ * Causes this drag session to request a new drop action from its delegate if no
5913
+ * drop session is currently active, then set it as the current drop action.
5914
+ *
5915
+ */
5916
+ invalidateDropAction(): void;
5917
+
5918
+
5919
+ /**
5920
+ * Causes this drag session to request a new drop action from its delegate if the specified drop session
5921
+ * is the currently active one, then set it as the current action for the this session.
5922
+ *
5923
+ */
5924
+ private _invalidateDropActionForDropSession(): void;
5925
+
5926
+
5905
5927
  /**
5906
5928
  * Updates the drop action displayed by this drag session, based on the current
5907
5929
  * source and target drop actions.
@@ -5997,6 +6019,15 @@ export class BMDropSession {
5997
6019
  */
5998
6020
  readonly dropAction: BMDropSessionAction;
5999
6021
 
6022
+ /**
6023
+ * Causes this drop session to request a new drop action from its delegate if it
6024
+ * is the current active drop session for the current drag session, then set it as the current action
6025
+ * for the drag session.
6026
+ *
6027
+ */
6028
+ invalidateDropAction(): void;
6029
+
6030
+
6000
6031
  /**
6001
6032
  * An array of drop previews that can be used to customize the drop animation. This property is only
6002
6033
  * initialized at the end of accepted drop sessions if the delegate object implemented the
@@ -3582,13 +3582,20 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
3582
3582
  // If this collection view was already waiting for the data set to insert some data from a drop,
3583
3583
  // play the generic drop animation for those previews
3584
3584
  if (this._dropPreviews) {
3585
- for (const preview of this._dropPreviews) {
3586
- preview.performDrop();
3587
- }
3585
+ BMAnimateWithBlock(() => {
3586
+ for (const preview of this._dropPreviews) {
3587
+ preview.performDrop();
3588
+ }
3589
+ }, {duration: 300, easing: 'easeInQuad'});
3588
3590
  }
3589
3591
 
3590
3592
  // If there are no items to accept, don't perform any other changes
3591
3593
  if (!session.dropItems.length) {
3594
+ BMAnimateWithBlock(() => {
3595
+ for (const preview of session.dropPreviews) {
3596
+ preview.performDrop();
3597
+ }
3598
+ }, {duration: 300, easing: 'easeInQuad'});
3592
3599
  return;
3593
3600
  }
3594
3601
 
@@ -3625,9 +3632,12 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
3625
3632
  this._dropPreviews = undefined;
3626
3633
  }
3627
3634
 
3628
- for (const preview of dropPreviews) {
3629
- preview.performDrop();
3630
- }
3635
+ BMAnimateWithBlock(() => {
3636
+ for (const preview of dropPreviews) {
3637
+ preview.performDrop();
3638
+ }
3639
+ }, {duration: 300, easing: 'easeInQuad'});
3640
+
3631
3641
  }
3632
3642
  }, _BMCollectionViewAsynchronousDropDelay);
3633
3643
  }
@@ -6811,7 +6821,10 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
6811
6821
  self.scrollOffset = offset;
6812
6822
 
6813
6823
  if (!currentContext) {
6814
- BMAnimationApply();
6824
+ return BMAnimationApply();
6825
+ }
6826
+ else {
6827
+ return new Promise(resolve => BMAnimationContextAddCompletionHandler(resolve));
6815
6828
  }
6816
6829
  }
6817
6830
  else {
@@ -375,6 +375,11 @@ BMDragSession.prototype = {
375
375
  return this._transferKind;
376
376
  },
377
377
 
378
+ /**
379
+ * Set to `YES` after this drag session finishes.
380
+ */
381
+ _finished: NO, // <Boolean>
382
+
378
383
  /**
379
384
  * Sets up the drag previews and indicator and appropriate event handlers and starts tracking
380
385
  * a drag originating from the event with which this drag session was initialized.
@@ -586,6 +591,8 @@ BMDragSession.prototype = {
586
591
  async _dragDidFinishWithEvent(event) {
587
592
  event.preventDefault();
588
593
 
594
+ this._finished = YES;
595
+
589
596
  this._action = this._dropAction;
590
597
 
591
598
  // Instruct the delegates that the session is about to end
@@ -855,7 +862,7 @@ BMDragSession.prototype = {
855
862
  const session = this._dropSessions.get(target);
856
863
  session._delegate.dropSessionDidEnter?.(session);
857
864
 
858
- let action = session._delegate.dropSessionDidUpdate?.(this) ?? BMDropSessionAction.actionWithKind(BMDropSessionActionKind.Ignore);
865
+ let action = session._delegate.dropSessionDidUpdate?.(session) ?? BMDropSessionAction.actionWithKind(BMDropSessionActionKind.Ignore);
859
866
 
860
867
  // If the target action is delete, the source delegate must be able to specify
861
868
  // a transfer of kind move
@@ -892,6 +899,11 @@ BMDragSession.prototype = {
892
899
  this._itemPreviewsUpdateIdentifier = setTimeout(() => {
893
900
  this._itemPreviewsUpdateIdentifier = undefined;
894
901
 
902
+ // If the session finished in the meantime, don't perform any further transition
903
+ if (this._finished) {
904
+ return;
905
+ }
906
+
895
907
  const newPreviews = new Map();
896
908
  if (this._dropTarget && this._dropTarget != this._sourceView) {
897
909
  // If there is a valid drop target, request item previews and apply them
@@ -912,6 +924,48 @@ BMDragSession.prototype = {
912
924
  }, 16);
913
925
  },
914
926
 
927
+
928
+ /**
929
+ * Causes this drag session to request a new drop action from its delegate if no
930
+ * drop session is currently active, then set it as the current drop action.
931
+ */
932
+ invalidateDropAction() {
933
+ if (this._finished || this._dropTarget && this._dropTarget != this._sourceView) {
934
+ return;
935
+ }
936
+
937
+ // Dispatch an update to the source view then update the drop action accordingly
938
+ const sourceAction = this._delegate.dragSessionDidUpdate?.(this);
939
+ if (sourceAction) {
940
+ this._sourceDropAction = sourceAction;
941
+ this._updateDropAction();
942
+ }
943
+ },
944
+
945
+
946
+ /**
947
+ * Causes this drag session to request a new drop action from its delegate if the specified drop session
948
+ * is the currently active one, then set it as the current action for the this session.
949
+ */
950
+ _invalidateDropActionForDropSession(session) {
951
+ if (this._finished || !this._dropTarget || this._dropTarget == this._sourceView) {
952
+ return;
953
+ }
954
+
955
+ const dropSession = this._dropSessions.get(this._dropTarget);
956
+ if (dropSession != session) {
957
+ return;
958
+ }
959
+
960
+ // Dispatch an update to the target view then update the drop action accordingly
961
+ const targetAction = session._delegate.dropSessionDidUpdate?.(session) ?? BMDropSessionAction.actionWithKind(BMDropSessionActionKind.Ignore);
962
+ if (targetAction) {
963
+ session._dropAction = targetAction;
964
+ this._targetDropAction = targetAction;
965
+ this._updateDropAction();
966
+ }
967
+ },
968
+
915
969
  /**
916
970
  * Updates the drop action displayed by this drag session, based on the current
917
971
  * source and target drop actions.
@@ -1109,6 +1163,15 @@ BMDropSession.prototype = {
1109
1163
  return this._dropAction;
1110
1164
  },
1111
1165
 
1166
+ /**
1167
+ * Causes this drop session to request a new drop action from its delegate if it
1168
+ * is the current active drop session for the current drag session, then set it as the current action
1169
+ * for the drag session.
1170
+ */
1171
+ invalidateDropAction() {
1172
+ this._dragSession._invalidateDropActionForDropSession(this);
1173
+ },
1174
+
1112
1175
  /**
1113
1176
  * An array of drop previews that can be used to customize the drop animation. This property is only
1114
1177
  * initialized at the end of accepted drop sessions if the delegate object implemented the
@@ -1282,7 +1282,9 @@ BMMenu.prototype = {
1282
1282
  // If the mouse pointer enters the submenu's frame, cause it to acquire focus
1283
1283
  // and resume events
1284
1284
  if (submenuFrame.intersectsPoint(currentPosition)) {
1285
- submenu._node.focus();
1285
+ if (submenu._node) {
1286
+ submenu._node.focus();
1287
+ }
1286
1288
  resumeEvents();
1287
1289
  return;
1288
1290
  }
@@ -5838,6 +5838,12 @@ declare class BMDragSession implements EventHandlerObject {
5838
5838
  */
5839
5839
  readonly transferKind?: BMDragTransferKind | null | undefined;
5840
5840
 
5841
+ /**
5842
+ * Set to `YES` after this drag session finishes.
5843
+ *
5844
+ */
5845
+ private _finished: boolean;
5846
+
5841
5847
  /**
5842
5848
  * Sets up the drag previews and indicator and appropriate event handlers and starts tracking
5843
5849
  * a drag originating from the event with which this drag session was initialized.
@@ -5902,6 +5908,22 @@ declare class BMDragSession implements EventHandlerObject {
5902
5908
  private _setDropTarget(target?: BMView | null | undefined): void;
5903
5909
 
5904
5910
 
5911
+ /**
5912
+ * Causes this drag session to request a new drop action from its delegate if no
5913
+ * drop session is currently active, then set it as the current drop action.
5914
+ *
5915
+ */
5916
+ invalidateDropAction(): void;
5917
+
5918
+
5919
+ /**
5920
+ * Causes this drag session to request a new drop action from its delegate if the specified drop session
5921
+ * is the currently active one, then set it as the current action for the this session.
5922
+ *
5923
+ */
5924
+ private _invalidateDropActionForDropSession(): void;
5925
+
5926
+
5905
5927
  /**
5906
5928
  * Updates the drop action displayed by this drag session, based on the current
5907
5929
  * source and target drop actions.
@@ -5997,6 +6019,15 @@ declare class BMDropSession {
5997
6019
  */
5998
6020
  readonly dropAction: BMDropSessionAction;
5999
6021
 
6022
+ /**
6023
+ * Causes this drop session to request a new drop action from its delegate if it
6024
+ * is the current active drop session for the current drag session, then set it as the current action
6025
+ * for the drag session.
6026
+ *
6027
+ */
6028
+ invalidateDropAction(): void;
6029
+
6030
+
6000
6031
  /**
6001
6032
  * An array of drop previews that can be used to customize the drop animation. This property is only
6002
6033
  * initialized at the end of accepted drop sessions if the delegate object implemented the