Skip to content

Commit 30c6c8f

Browse files
authored
refactor(cdk/drag-drop): convert all directives to standalone (#26135)
* refactor(cdk/drag-drop): convert all directives to standalone * refactor(cdk/drag-drop): import directives in the module * fix(cdk/drag-drop): remove declarations from DragDropModule * refactor(cdk/drag-drop): update public api guard
1 parent a007b92 commit 30c6c8f

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

src/cdk/drag-drop/directives/drag-handle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const CDK_DRAG_HANDLE = new InjectionToken<CdkDragHandle>('CdkDragHandle'
3131
/** Handle that can be used to drag a CdkDrag instance. */
3232
@Directive({
3333
selector: '[cdkDragHandle]',
34+
standalone: true,
3435
host: {
3536
'class': 'cdk-drag-handle',
3637
},

src/cdk/drag-drop/directives/drag-placeholder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const CDK_DRAG_PLACEHOLDER = new InjectionToken<CdkDragPlaceholder>('CdkD
2121
*/
2222
@Directive({
2323
selector: 'ng-template[cdkDragPlaceholder]',
24+
standalone: true,
2425
providers: [{provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder}],
2526
})
2627
export class CdkDragPlaceholder<T = any> {

src/cdk/drag-drop/directives/drag-preview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const CDK_DRAG_PREVIEW = new InjectionToken<CdkDragPreview>('CdkDragPrevi
2222
*/
2323
@Directive({
2424
selector: 'ng-template[cdkDragPreview]',
25+
standalone: true,
2526
providers: [{provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview}],
2627
})
2728
export class CdkDragPreview<T = any> {

src/cdk/drag-drop/directives/drag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const DRAG_HOST_CLASS = 'cdk-drag';
6262
@Directive({
6363
selector: '[cdkDrag]',
6464
exportAs: 'cdkDrag',
65+
standalone: true,
6566
host: {
6667
'class': DRAG_HOST_CLASS,
6768
'[class.cdk-drag-disabled]': 'disabled',

src/cdk/drag-drop/directives/drop-list-group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const CDK_DROP_LIST_GROUP = new InjectionToken<CdkDropListGroup<unknown>>
2727
@Directive({
2828
selector: '[cdkDropListGroup]',
2929
exportAs: 'cdkDropListGroup',
30+
standalone: true,
3031
providers: [{provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup}],
3132
})
3233
export class CdkDropListGroup<T> implements OnDestroy {

src/cdk/drag-drop/directives/drop-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const CDK_DROP_LIST = new InjectionToken<CdkDropList>('CdkDropList');
6060
@Directive({
6161
selector: '[cdkDropList], cdk-drop-list',
6262
exportAs: 'cdkDropList',
63+
standalone: true,
6364
providers: [
6465
// Prevent child drop lists from picking up the same group as their parent.
6566
{provide: CDK_DROP_LIST_GROUP, useValue: undefined},

src/cdk/drag-drop/drag-drop-module.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,18 @@ import {CdkDragPreview} from './directives/drag-preview';
1616
import {CdkDragPlaceholder} from './directives/drag-placeholder';
1717
import {DragDrop} from './drag-drop';
1818

19+
const DRAG_DROP_DIRECTIVES = [
20+
CdkDropList,
21+
CdkDropListGroup,
22+
CdkDrag,
23+
CdkDragHandle,
24+
CdkDragPreview,
25+
CdkDragPlaceholder,
26+
];
27+
1928
@NgModule({
20-
declarations: [
21-
CdkDropList,
22-
CdkDropListGroup,
23-
CdkDrag,
24-
CdkDragHandle,
25-
CdkDragPreview,
26-
CdkDragPlaceholder,
27-
],
28-
exports: [
29-
CdkScrollableModule,
30-
CdkDropList,
31-
CdkDropListGroup,
32-
CdkDrag,
33-
CdkDragHandle,
34-
CdkDragPreview,
35-
CdkDragPlaceholder,
36-
],
29+
imports: DRAG_DROP_DIRECTIVES,
30+
exports: [CdkScrollableModule, ...DRAG_DROP_DIRECTIVES],
3731
providers: [DragDrop],
3832
})
3933
export class DragDropModule {}

tools/public_api_guard/cdk/drag-drop.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
9090
setFreeDragPosition(value: Point): void;
9191
readonly started: EventEmitter<CdkDragStart>;
9292
// (undocumented)
93-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDrag<any>, "[cdkDrag]", ["cdkDrag"], { "data": "cdkDragData"; "lockAxis": "cdkDragLockAxis"; "rootElementSelector": "cdkDragRootElement"; "boundaryElement": "cdkDragBoundary"; "dragStartDelay": "cdkDragStartDelay"; "freeDragPosition": "cdkDragFreeDragPosition"; "disabled": "cdkDragDisabled"; "constrainPosition": "cdkDragConstrainPosition"; "previewClass": "cdkDragPreviewClass"; "previewContainer": "cdkDragPreviewContainer"; }, { "started": "cdkDragStarted"; "released": "cdkDragReleased"; "ended": "cdkDragEnded"; "entered": "cdkDragEntered"; "exited": "cdkDragExited"; "dropped": "cdkDragDropped"; "moved": "cdkDragMoved"; }, ["_previewTemplate", "_placeholderTemplate", "_handles"], never, false, never>;
93+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDrag<any>, "[cdkDrag]", ["cdkDrag"], { "data": "cdkDragData"; "lockAxis": "cdkDragLockAxis"; "rootElementSelector": "cdkDragRootElement"; "boundaryElement": "cdkDragBoundary"; "dragStartDelay": "cdkDragStartDelay"; "freeDragPosition": "cdkDragFreeDragPosition"; "disabled": "cdkDragDisabled"; "constrainPosition": "cdkDragConstrainPosition"; "previewClass": "cdkDragPreviewClass"; "previewContainer": "cdkDragPreviewContainer"; }, { "started": "cdkDragStarted"; "released": "cdkDragReleased"; "ended": "cdkDragEnded"; "entered": "cdkDragEntered"; "exited": "cdkDragExited"; "dropped": "cdkDragDropped"; "moved": "cdkDragMoved"; }, ["_previewTemplate", "_placeholderTemplate", "_handles"], never, true, never>;
9494
// (undocumented)
9595
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDrag<any>, [null, { optional: true; skipSelf: true; }, null, null, null, { optional: true; }, { optional: true; }, null, null, { optional: true; self: true; }, { optional: true; skipSelf: true; }]>;
9696
}
@@ -153,7 +153,7 @@ export class CdkDragHandle implements OnDestroy {
153153
_parentDrag: {} | undefined;
154154
readonly _stateChanges: Subject<CdkDragHandle>;
155155
// (undocumented)
156-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragHandle, "[cdkDragHandle]", never, { "disabled": "cdkDragHandleDisabled"; }, {}, never, never, false, never>;
156+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragHandle, "[cdkDragHandle]", never, { "disabled": "cdkDragHandleDisabled"; }, {}, never, never, true, never>;
157157
// (undocumented)
158158
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDragHandle, [null, { optional: true; skipSelf: true; }]>;
159159
}
@@ -183,7 +183,7 @@ export class CdkDragPlaceholder<T = any> {
183183
// (undocumented)
184184
templateRef: TemplateRef<T>;
185185
// (undocumented)
186-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragPlaceholder<any>, "ng-template[cdkDragPlaceholder]", never, { "data": "data"; }, {}, never, never, false, never>;
186+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragPlaceholder<any>, "ng-template[cdkDragPlaceholder]", never, { "data": "data"; }, {}, never, never, true, never>;
187187
// (undocumented)
188188
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDragPlaceholder<any>, never>;
189189
}
@@ -197,7 +197,7 @@ export class CdkDragPreview<T = any> {
197197
// (undocumented)
198198
templateRef: TemplateRef<T>;
199199
// (undocumented)
200-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragPreview<any>, "ng-template[cdkDragPreview]", never, { "data": "data"; "matchSize": "matchSize"; }, {}, never, never, false, never>;
200+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragPreview<any>, "ng-template[cdkDragPreview]", never, { "data": "data"; "matchSize": "matchSize"; }, {}, never, never, true, never>;
201201
// (undocumented)
202202
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDragPreview<any>, never>;
203203
}
@@ -250,7 +250,7 @@ export class CdkDropList<T = any> implements OnDestroy {
250250
sortingDisabled: BooleanInput;
251251
sortPredicate: (index: number, drag: CdkDrag, drop: CdkDropList) => boolean;
252252
// (undocumented)
253-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDropList<any>, "[cdkDropList], cdk-drop-list", ["cdkDropList"], { "connectedTo": "cdkDropListConnectedTo"; "data": "cdkDropListData"; "orientation": "cdkDropListOrientation"; "id": "id"; "lockAxis": "cdkDropListLockAxis"; "disabled": "cdkDropListDisabled"; "sortingDisabled": "cdkDropListSortingDisabled"; "enterPredicate": "cdkDropListEnterPredicate"; "sortPredicate": "cdkDropListSortPredicate"; "autoScrollDisabled": "cdkDropListAutoScrollDisabled"; "autoScrollStep": "cdkDropListAutoScrollStep"; }, { "dropped": "cdkDropListDropped"; "entered": "cdkDropListEntered"; "exited": "cdkDropListExited"; "sorted": "cdkDropListSorted"; }, never, never, false, never>;
253+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDropList<any>, "[cdkDropList], cdk-drop-list", ["cdkDropList"], { "connectedTo": "cdkDropListConnectedTo"; "data": "cdkDropListData"; "orientation": "cdkDropListOrientation"; "id": "id"; "lockAxis": "cdkDropListLockAxis"; "disabled": "cdkDropListDisabled"; "sortingDisabled": "cdkDropListSortingDisabled"; "enterPredicate": "cdkDropListEnterPredicate"; "sortPredicate": "cdkDropListSortPredicate"; "autoScrollDisabled": "cdkDropListAutoScrollDisabled"; "autoScrollStep": "cdkDropListAutoScrollStep"; }, { "dropped": "cdkDropListDropped"; "entered": "cdkDropListEntered"; "exited": "cdkDropListExited"; "sorted": "cdkDropListSorted"; }, never, never, true, never>;
254254
// (undocumented)
255255
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDropList<any>, [null, null, null, null, { optional: true; }, { optional: true; skipSelf: true; }, { optional: true; }]>;
256256
}
@@ -263,7 +263,7 @@ export class CdkDropListGroup<T> implements OnDestroy {
263263
// (undocumented)
264264
ngOnDestroy(): void;
265265
// (undocumented)
266-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDropListGroup<any>, "[cdkDropListGroup]", ["cdkDropListGroup"], { "disabled": "cdkDropListGroupDisabled"; }, {}, never, never, false, never>;
266+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDropListGroup<any>, "[cdkDropListGroup]", ["cdkDropListGroup"], { "disabled": "cdkDropListGroupDisabled"; }, {}, never, never, true, never>;
267267
// (undocumented)
268268
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDropListGroup<any>, never>;
269269
}
@@ -323,7 +323,7 @@ export class DragDropModule {
323323
// (undocumented)
324324
static ɵinj: i0.ɵɵInjectorDeclaration<DragDropModule>;
325325
// (undocumented)
326-
static ɵmod: i0.ɵɵNgModuleDeclaration<DragDropModule, [typeof i1.CdkDropList, typeof i2.CdkDropListGroup, typeof i3.CdkDrag, typeof i4.CdkDragHandle, typeof i5.CdkDragPreview, typeof i6.CdkDragPlaceholder], never, [typeof i7.CdkScrollableModule, typeof i1.CdkDropList, typeof i2.CdkDropListGroup, typeof i3.CdkDrag, typeof i4.CdkDragHandle, typeof i5.CdkDragPreview, typeof i6.CdkDragPlaceholder]>;
326+
static ɵmod: i0.ɵɵNgModuleDeclaration<DragDropModule, never, [typeof i1.CdkDropList, typeof i2.CdkDropListGroup, typeof i3.CdkDrag, typeof i4.CdkDragHandle, typeof i5.CdkDragPreview, typeof i6.CdkDragPlaceholder], [typeof i7.CdkScrollableModule, typeof i1.CdkDropList, typeof i2.CdkDropListGroup, typeof i3.CdkDrag, typeof i4.CdkDragHandle, typeof i5.CdkDragPreview, typeof i6.CdkDragPlaceholder]>;
327327
}
328328

329329
// @public

0 commit comments

Comments
 (0)