1
1
import { Directionality } from '@angular/cdk/bidi' ;
2
2
import { _supportsShadowDom } from '@angular/cdk/platform' ;
3
- import { ViewportRuler } from '@angular/cdk/scrolling' ;
3
+ import { CdkScrollable , ViewportRuler } from '@angular/cdk/scrolling' ;
4
4
import {
5
5
createMouseEvent ,
6
6
createTouchEvent ,
@@ -47,7 +47,9 @@ import {
47
47
stopDraggingViaTouch ,
48
48
tickAnimationFrames ,
49
49
} from './test-utils.spec' ;
50
- import { NgFor } from '@angular/common' ;
50
+ import { NgClass , NgFor , NgIf , NgTemplateOutlet } from '@angular/common' ;
51
+ import { CdkDragPreview } from './drag-preview' ;
52
+ import { CdkDragPlaceholder } from './drag-placeholder' ;
51
53
52
54
export const ITEM_HEIGHT = 25 ;
53
55
export const ITEM_WIDTH = 75 ;
@@ -4026,9 +4028,7 @@ export function defineCommonDropListTests(config: {
4026
4028
) ;
4027
4029
4028
4030
it ( 'should set the receiving class when the list is wrapped in an OnPush component' , fakeAsync ( ( ) => {
4029
- const fixture = createComponent ( ConnectedDropListsInOnPush , {
4030
- extraDeclarations : [ DraggableInOnPushDropZone ] ,
4031
- } ) ;
4031
+ const fixture = createComponent ( ConnectedDropListsInOnPush ) ;
4032
4032
fixture . detectChanges ( ) ;
4033
4033
4034
4034
const dropZones = Array . from < HTMLElement > (
@@ -4369,9 +4369,7 @@ export function defineCommonDropListTests(config: {
4369
4369
'should toggle a class when dragging an item inside a wrapper component component ' +
4370
4370
'with OnPush change detection' ,
4371
4371
fakeAsync ( ( ) => {
4372
- const fixture = createComponent ( ConnectedWrappedDropZones , {
4373
- extraDeclarations : [ WrappedDropContainerComponent ] ,
4374
- } ) ;
4372
+ const fixture = createComponent ( ConnectedWrappedDropZones ) ;
4375
4373
fixture . detectChanges ( ) ;
4376
4374
4377
4375
const [ startZone , targetZone ] = fixture . nativeElement . querySelectorAll ( '.cdk-drop-list' ) ;
@@ -4832,6 +4830,8 @@ export function getHorizontalFixtures(listOrientation: Exclude<DropListOrientati
4832
4830
encapsulation : ViewEncapsulation . None ,
4833
4831
styles : HORIZONTAL_FIXTURE_STYLES ,
4834
4832
template : HORIZONTAL_FIXTURE_TEMPLATE ,
4833
+ standalone : true ,
4834
+ imports : [ CdkDropList , CdkDrag ] ,
4835
4835
} )
4836
4836
class DraggableInHorizontalDropZone implements AfterViewInit {
4837
4837
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -4858,6 +4858,8 @@ export function getHorizontalFixtures(listOrientation: Exclude<DropListOrientati
4858
4858
}
4859
4859
4860
4860
@Component ( {
4861
+ standalone : true ,
4862
+ imports : [ CdkDropList , CdkDrag ] ,
4861
4863
template : HORIZONTAL_FIXTURE_TEMPLATE ,
4862
4864
4863
4865
// Note that it needs a margin to ensure that it's not flush against the viewport
@@ -4911,6 +4913,8 @@ export function getHorizontalFixtures(listOrientation: Exclude<DropListOrientati
4911
4913
}
4912
4914
</div>
4913
4915
` ,
4916
+ standalone : true ,
4917
+ imports : [ CdkDropList , CdkDrag , CdkDragPreview ] ,
4914
4918
} )
4915
4919
class DraggableInHorizontalFlexDropZoneWithMatchSizePreview {
4916
4920
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -4993,6 +4997,8 @@ export class DraggableInDropZone implements AfterViewInit {
4993
4997
selector : 'draggable-in-on-push-zone' ,
4994
4998
template : DROP_ZONE_FIXTURE_TEMPLATE ,
4995
4999
changeDetection : ChangeDetectionStrategy . OnPush ,
5000
+ standalone : true ,
5001
+ imports : [ CdkDropList , CdkDrag , NgFor ] ,
4996
5002
} )
4997
5003
class DraggableInOnPushDropZone extends DraggableInDropZone { }
4998
5004
@@ -5003,6 +5009,8 @@ class DraggableInOnPushDropZone extends DraggableInDropZone {}
5003
5009
<draggable-in-on-push-zone></draggable-in-on-push-zone>
5004
5010
</div>
5005
5011
` ,
5012
+ standalone : true ,
5013
+ imports : [ CdkDropListGroup , DraggableInOnPushDropZone ] ,
5006
5014
} )
5007
5015
class ConnectedDropListsInOnPush { }
5008
5016
@@ -5018,6 +5026,8 @@ class ConnectedDropListsInOnPush {}
5018
5026
margin: 10vw 0 0 10vw;
5019
5027
}
5020
5028
` ,
5029
+ standalone : true ,
5030
+ imports : [ CdkDropList , CdkDrag , NgFor ] ,
5021
5031
} )
5022
5032
export class DraggableInScrollableVerticalDropZone extends DraggableInDropZone {
5023
5033
constructor ( elementRef : ElementRef ) {
@@ -5045,6 +5055,8 @@ export class DraggableInScrollableVerticalDropZone extends DraggableInDropZone {
5045
5055
margin: 10vw 0 0 10vw;
5046
5056
}
5047
5057
` ,
5058
+ standalone : true ,
5059
+ imports : [ CdkDropList , CdkDrag , NgFor , CdkScrollable ] ,
5048
5060
} )
5049
5061
class DraggableInScrollableParentContainer extends DraggableInDropZone implements AfterViewInit {
5050
5062
@ViewChild ( 'scrollContainer' ) scrollContainer : ElementRef < HTMLElement > ;
@@ -5091,6 +5103,8 @@ class DraggableInScrollableParentContainer extends DraggableInDropZone implement
5091
5103
}
5092
5104
</div>
5093
5105
` ,
5106
+ standalone : true ,
5107
+ imports : [ CdkDropList , CdkDrag ] ,
5094
5108
} )
5095
5109
class DraggableInDropZoneWithContainer extends DraggableInDropZone { }
5096
5110
@@ -5120,6 +5134,8 @@ class DraggableInDropZoneWithContainer extends DraggableInDropZone {}
5120
5134
}
5121
5135
</div>
5122
5136
` ,
5137
+ standalone : true ,
5138
+ imports : [ CdkDropList , CdkDrag , CdkDragPreview , NgIf ] ,
5123
5139
} )
5124
5140
class DraggableInDropZoneWithCustomPreview {
5125
5141
@ViewChild ( CdkDropList ) dropInstance : CdkDropList ;
@@ -5153,6 +5169,8 @@ class DraggableInDropZoneWithCustomPreview {
5153
5169
}
5154
5170
</div>
5155
5171
` ,
5172
+ standalone : true ,
5173
+ imports : [ CdkDropList , CdkDrag , CdkDragPreview ] ,
5156
5174
} )
5157
5175
class DraggableInDropZoneWithCustomTextOnlyPreview {
5158
5176
@ViewChild ( CdkDropList ) dropInstance : CdkDropList ;
@@ -5174,6 +5192,8 @@ class DraggableInDropZoneWithCustomTextOnlyPreview {
5174
5192
}
5175
5193
</div>
5176
5194
` ,
5195
+ standalone : true ,
5196
+ imports : [ CdkDropList , CdkDrag , CdkDragPreview ] ,
5177
5197
} )
5178
5198
class DraggableInDropZoneWithCustomMultiNodePreview {
5179
5199
@ViewChild ( CdkDropList ) dropInstance : CdkDropList ;
@@ -5205,6 +5225,8 @@ class DraggableInDropZoneWithCustomMultiNodePreview {
5205
5225
height: ${ ITEM_HEIGHT * 3 } px;
5206
5226
}
5207
5227
` ,
5228
+ standalone : true ,
5229
+ imports : [ CdkDropList , CdkDrag , CdkDragPlaceholder , NgClass ] ,
5208
5230
} )
5209
5231
class DraggableInDropZoneWithCustomPlaceholder {
5210
5232
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -5225,6 +5247,8 @@ class DraggableInDropZoneWithCustomPlaceholder {
5225
5247
}
5226
5248
</div>
5227
5249
` ,
5250
+ standalone : true ,
5251
+ imports : [ CdkDropList , CdkDrag , CdkDragPlaceholder ] ,
5228
5252
} )
5229
5253
class DraggableInDropZoneWithCustomTextOnlyPlaceholder {
5230
5254
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -5245,6 +5269,8 @@ class DraggableInDropZoneWithCustomTextOnlyPlaceholder {
5245
5269
}
5246
5270
</div>
5247
5271
` ,
5272
+ standalone : true ,
5273
+ imports : [ CdkDropList , CdkDrag , CdkDragPlaceholder ] ,
5248
5274
} )
5249
5275
class DraggableInDropZoneWithCustomMultiNodePlaceholder {
5250
5276
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -5319,6 +5345,8 @@ const CONNECTED_DROP_ZONES_TEMPLATE = `
5319
5345
encapsulation : ViewEncapsulation . None ,
5320
5346
styles : CONNECTED_DROP_ZONES_STYLES ,
5321
5347
template : CONNECTED_DROP_ZONES_TEMPLATE ,
5348
+ standalone : true ,
5349
+ imports : [ CdkDropList , CdkDrag ] ,
5322
5350
} )
5323
5351
class ConnectedDropZones implements AfterViewInit {
5324
5352
@ViewChildren ( CdkDrag ) rawDragItems : QueryList < CdkDrag > ;
@@ -5352,6 +5380,8 @@ class ConnectedDropZones implements AfterViewInit {
5352
5380
encapsulation : ViewEncapsulation . ShadowDom ,
5353
5381
styles : CONNECTED_DROP_ZONES_STYLES ,
5354
5382
template : `@if (true) {${ CONNECTED_DROP_ZONES_TEMPLATE } }` ,
5383
+ standalone : true ,
5384
+ imports : [ CdkDropList , CdkDrag ] ,
5355
5385
} )
5356
5386
class ConnectedDropZonesInsideShadowRootWithNgIf extends ConnectedDropZones { }
5357
5387
@@ -5378,8 +5408,8 @@ class ConnectedDropZonesInsideShadowRootWithNgIf extends ConnectedDropZones {}
5378
5408
[cdkDropListData]="todo"
5379
5409
(cdkDropListDropped)="droppedSpy($event)">
5380
5410
@for (item of todo; track item) {
5381
- <div [cdkDragData]="item" cdkDrag>{{item}}</div>
5382
- }
5411
+ <div [cdkDragData]="item" cdkDrag>{{item}}</div>
5412
+ }
5383
5413
</div>
5384
5414
5385
5415
<div
@@ -5392,6 +5422,8 @@ class ConnectedDropZonesInsideShadowRootWithNgIf extends ConnectedDropZones {}
5392
5422
</div>
5393
5423
</div>
5394
5424
` ,
5425
+ standalone : true ,
5426
+ imports : [ CdkDropList , CdkDrag , CdkDropListGroup ] ,
5395
5427
} )
5396
5428
class ConnectedDropZonesViaGroupDirective extends ConnectedDropZones {
5397
5429
groupDisabled = false ;
@@ -5430,6 +5462,8 @@ class ConnectedDropZonesViaGroupDirective extends ConnectedDropZones {
5430
5462
<div cdkDrag>Two</div>
5431
5463
</div>
5432
5464
` ,
5465
+ standalone : true ,
5466
+ imports : [ CdkDropList , CdkDrag ] ,
5433
5467
} )
5434
5468
class ConnectedDropZonesWithSingleItems {
5435
5469
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -5449,6 +5483,8 @@ class ConnectedDropZonesWithSingleItems {
5449
5483
<div cdkDropList #listTwo="cdkDropList"></div>
5450
5484
</div>
5451
5485
` ,
5486
+ standalone : true ,
5487
+ imports : [ CdkDropList , CdkDropListGroup ] ,
5452
5488
} )
5453
5489
class NestedDropListGroups {
5454
5490
@ViewChild ( 'group' ) group : CdkDropListGroup < CdkDropList > ;
@@ -5460,11 +5496,15 @@ class NestedDropListGroups {
5460
5496
template : `
5461
5497
<ng-container cdkDropList></ng-container>
5462
5498
` ,
5499
+ standalone : true ,
5500
+ imports : [ CdkDropList ] ,
5463
5501
} )
5464
5502
class DropListOnNgContainer { }
5465
5503
5466
5504
@Component ( {
5467
5505
changeDetection : ChangeDetectionStrategy . OnPush ,
5506
+ standalone : true ,
5507
+ imports : [ CdkDropList , CdkDrag ] ,
5468
5508
template : `
5469
5509
<div cdkDropList style="width: 100px; background: pink;">
5470
5510
@for (item of items; track item) {
@@ -5487,6 +5527,24 @@ class DraggableInDropZoneWithoutEvents {
5487
5527
] ;
5488
5528
}
5489
5529
5530
+ /** Component that wraps a drop container and uses OnPush change detection. */
5531
+ @Component ( {
5532
+ selector : 'wrapped-drop-container' ,
5533
+ template : `
5534
+ <div cdkDropList [cdkDropListData]="items">
5535
+ @for (item of items; track item) {
5536
+ <div cdkDrag>{{item}}</div>
5537
+ }
5538
+ </div>
5539
+ ` ,
5540
+ standalone : true ,
5541
+ imports : [ CdkDropList , CdkDrag ] ,
5542
+ changeDetection : ChangeDetectionStrategy . OnPush ,
5543
+ } )
5544
+ class WrappedDropContainerComponent {
5545
+ @Input ( ) items : string [ ] ;
5546
+ }
5547
+
5490
5548
@Component ( {
5491
5549
encapsulation : ViewEncapsulation . None ,
5492
5550
styles : `
@@ -5509,6 +5567,8 @@ class DraggableInDropZoneWithoutEvents {
5509
5567
<wrapped-drop-container [items]="done"></wrapped-drop-container>
5510
5568
</div>
5511
5569
` ,
5570
+ standalone : true ,
5571
+ imports : [ CdkDropListGroup , WrappedDropContainerComponent ] ,
5512
5572
} )
5513
5573
class ConnectedWrappedDropZones {
5514
5574
todo = [ 'Zero' , 'One' , 'Two' , 'Three' ] ;
@@ -5538,6 +5598,8 @@ class ConnectedWrappedDropZones {
5538
5598
}
5539
5599
</div>
5540
5600
` ,
5601
+ standalone : true ,
5602
+ imports : [ CdkDropList , CdkDrag ] ,
5541
5603
} )
5542
5604
class DraggableWithCanvasInDropZone extends DraggableInDropZone implements AfterViewInit {
5543
5605
constructor ( elementRef : ElementRef < HTMLElement > ) {
@@ -5582,25 +5644,11 @@ class DraggableWithCanvasInDropZone extends DraggableInDropZone implements After
5582
5644
}
5583
5645
</div>
5584
5646
` ,
5647
+ standalone : true ,
5648
+ imports : [ CdkDropList , CdkDrag ] ,
5585
5649
} )
5586
5650
class DraggableWithInvalidCanvasInDropZone extends DraggableInDropZone { }
5587
5651
5588
- /** Component that wraps a drop container and uses OnPush change detection. */
5589
- @Component ( {
5590
- selector : 'wrapped-drop-container' ,
5591
- template : `
5592
- <div cdkDropList [cdkDropListData]="items">
5593
- @for (item of items; track item) {
5594
- <div cdkDrag>{{item}}</div>
5595
- }
5596
- </div>
5597
- ` ,
5598
- changeDetection : ChangeDetectionStrategy . OnPush ,
5599
- } )
5600
- class WrappedDropContainerComponent {
5601
- @Input ( ) items : string [ ] ;
5602
- }
5603
-
5604
5652
@Component ( {
5605
5653
styles : `
5606
5654
:host {
@@ -5636,6 +5684,8 @@ class WrappedDropContainerComponent {
5636
5684
(cdkDragReleased)="itemDragReleasedSpy($event)">
5637
5685
</div>
5638
5686
</div>` ,
5687
+ standalone : true ,
5688
+ imports : [ CdkDrag ] ,
5639
5689
} )
5640
5690
class NestedDragsComponent {
5641
5691
@ViewChild ( 'container' ) container : ElementRef ;
@@ -5689,6 +5739,8 @@ class NestedDragsComponent {
5689
5739
</div>
5690
5740
</ng-template>
5691
5741
` ,
5742
+ standalone : true ,
5743
+ imports : [ CdkDrag , NgTemplateOutlet ] ,
5692
5744
} )
5693
5745
class NestedDragsThroughTemplate {
5694
5746
@ViewChild ( 'container' ) container : ElementRef ;
@@ -5713,6 +5765,8 @@ class NestedDragsThroughTemplate {
5713
5765
</div>
5714
5766
</div>
5715
5767
` ,
5768
+ standalone : true ,
5769
+ imports : [ CdkDropList , CdkDrag ] ,
5716
5770
} )
5717
5771
class NestedDropZones {
5718
5772
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
@@ -5723,6 +5777,8 @@ class NestedDropZones {
5723
5777
5724
5778
@Component ( {
5725
5779
template : `<div cdkDropList></div>` ,
5780
+ standalone : true ,
5781
+ imports : [ CdkDropList ] ,
5726
5782
} )
5727
5783
class PlainStandaloneDropList {
5728
5784
@ViewChild ( CdkDropList ) dropList : CdkDropList ;
@@ -5764,6 +5820,8 @@ class PlainStandaloneDropList {
5764
5820
</div>
5765
5821
</div>
5766
5822
` ,
5823
+ standalone : true ,
5824
+ imports : [ CdkDropList , CdkDrag ] ,
5767
5825
} )
5768
5826
class ConnectedDropZonesWithIntermediateSibling extends ConnectedDropZones { }
5769
5827
@@ -5795,6 +5853,8 @@ class ConnectedDropZonesWithIntermediateSibling extends ConnectedDropZones {}
5795
5853
}
5796
5854
</div>
5797
5855
` ,
5856
+ standalone : true ,
5857
+ imports : [ CdkDropList , CdkDrag ] ,
5798
5858
} )
5799
5859
class DraggableWithInputsInDropZone extends DraggableInDropZone {
5800
5860
inputValue = 'hello' ;
@@ -5816,6 +5876,8 @@ class DraggableWithInputsInDropZone extends DraggableInDropZone {
5816
5876
}
5817
5877
</div>
5818
5878
` ,
5879
+ standalone : true ,
5880
+ imports : [ CdkDropList , CdkDrag ] ,
5819
5881
} )
5820
5882
class DraggableWithRadioInputsInDropZone {
5821
5883
@ViewChildren ( CdkDrag ) dragItems : QueryList < CdkDrag > ;
0 commit comments