Skip to content

Commit 7626565

Browse files
committed
fix: bump minimum dnd-core to v9
1 parent 4e92160 commit 7626565

File tree

14 files changed

+98
-62
lines changed

14 files changed

+98
-62
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"repository": "https://github.com/cormacrelf/angular-skyhook",
88
"dependencies": {
9-
"dnd-core": "^8.0.0",
9+
"dnd-core": "^9.0.0",
1010
"tslib": "^1.9.0"
1111
},
1212
"peerDependencies": {

packages/core/src/connector.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class SkyhookDndService {
114114

115115
/** @ignore */
116116
constructor(
117-
@Inject(DRAG_DROP_MANAGER) private manager: DragDropManager<any>,
117+
@Inject(DRAG_DROP_MANAGER) private manager: DragDropManager,
118118
private ngZone: NgZone
119119
) { }
120120

packages/core/src/dnd.module.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
DragPreviewDirective
1212
} from './dnd.directive';
1313

14-
import { DRAG_DROP_BACKEND, DRAG_DROP_MANAGER } from './tokens';
14+
import { DRAG_DROP_BACKEND, DRAG_DROP_BACKEND_OPTIONS, DRAG_DROP_BACKEND_DEBUG_MODE, DRAG_DROP_MANAGER } from './tokens';
1515

1616
import {
1717
createDragDropManager,
@@ -41,11 +41,13 @@ export function unpackBackendForEs5Users(backendOrModule: any) {
4141
export function managerFactory(
4242
backendFactory: BackendFactory,
4343
zone: NgZone,
44-
context = { window: window }
45-
): DragDropManager<any> {
44+
context = { window: window },
45+
backendOptions?: any,
46+
debugMode?: boolean,
47+
): DragDropManager {
4648
backendFactory = unpackBackendForEs5Users(backendFactory);
4749
return zone.runOutsideAngular(() =>
48-
createDragDropManager(backendFactory, context)
50+
createDragDropManager(backendFactory, context, backendOptions, debugMode)
4951
);
5052
}
5153

@@ -69,6 +71,8 @@ export function managerFactory(
6971
export interface BackendInput {
7072
/** A plain backend, for example the HTML5Backend. */
7173
backend: BackendFactory;
74+
options?: any;
75+
debug?: boolean,
7276
}
7377

7478
/**
@@ -97,14 +101,15 @@ export interface BackendInput {
97101
export interface BackendFactoryInput {
98102
/** See above. */
99103
backendFactory: () => BackendFactory;
104+
debug?: boolean;
100105
}
101106

102107
/** @ignore */
103108
const EXPORTS = [
104109
DragSourceDirective,
105110
DropTargetDirective,
106111
DragPreviewDirective,
107-
]
112+
];
108113

109114
@NgModule({
110115
declarations: EXPORTS,
@@ -124,10 +129,25 @@ export class SkyhookDndModule {
124129
useFactory: (backendOrBackendFactory as BackendFactoryInput)
125130
.backendFactory
126131
},
132+
{
133+
provide: DRAG_DROP_BACKEND_OPTIONS,
134+
// whichever one they have provided, the other will be undefined
135+
useValue: (backendOrBackendFactory as BackendInput).options,
136+
},
137+
{
138+
provide: DRAG_DROP_BACKEND_DEBUG_MODE,
139+
// whichever one they have provided, the other will be undefined
140+
useValue: backendOrBackendFactory.debug,
141+
},
127142
{
128143
provide: DRAG_DROP_MANAGER,
129144
useFactory: managerFactory,
130-
deps: [DRAG_DROP_BACKEND, NgZone]
145+
deps: [
146+
DRAG_DROP_BACKEND,
147+
NgZone,
148+
DRAG_DROP_BACKEND_OPTIONS,
149+
DRAG_DROP_BACKEND_DEBUG_MODE
150+
]
131151
},
132152
SkyhookDndService
133153
]

packages/core/src/internal/connection-factory.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import { scheduleMicroTaskAfter } from './scheduleMicroTaskAfter';
2828

2929
export interface FactoryArgs<TMonitor, TConnector> {
3030
createHandler: (handlerMonitor: any) => any;
31-
createMonitor: (manager: DragDropManager<any>) => TMonitor;
31+
createMonitor: (manager: DragDropManager) => TMonitor;
3232
createConnector: (
3333
backend: Backend
3434
) => { receiveHandlerId(handlerId: any): void; hooks: TConnector };
3535
registerHandler: (
3636
type: any,
3737
handler: any,
38-
manager: DragDropManager<any>
38+
manager: DragDropManager
3939
) => {
4040
handlerId: any;
4141
unregister: Subscription | Function;
@@ -72,7 +72,7 @@ export class Connection<TMonitor extends DragSourceMonitor | DropTargetMonitor,
7272

7373
constructor(
7474
private factoryArgs: FactoryArgs<TMonitor, TConnector>,
75-
private manager: DragDropManager<any>,
75+
private manager: DragDropManager,
7676
private skyhookZone: Zone,
7777
initialType: TypeOrTypeArray | undefined
7878
) {
@@ -252,15 +252,15 @@ export class Connection<TMonitor extends DragSourceMonitor | DropTargetMonitor,
252252
export interface SourceConstructor<Item = {}, DropResult = {}> {
253253
new (
254254
factoryArgs: FactoryArgs<DragSourceMonitor, DragSourceConnector>,
255-
manager: DragDropManager<any>,
255+
manager: DragDropManager,
256256
skyhookZone: Zone,
257257
initialType: string | symbol | undefined
258258
): t.DragSource<Item, DropResult>;
259259
}
260260
export interface TargetConstructor {
261261
new (
262262
factoryArgs: FactoryArgs<DropTargetMonitor, DropTargetConnector>,
263-
manager: DragDropManager<any>,
263+
manager: DragDropManager,
264264
skyhookZone: Zone,
265265
initialType: TypeOrTypeArray | undefined
266266
): t.DropTarget;

packages/core/src/internal/drag-layer-connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class DragLayerConnectionClass implements DragLayer {
1414
private subscription = new Subscription();
1515

1616

17-
constructor(private manager: DragDropManager<any>, private zone: Zone) {
17+
constructor(private manager: DragDropManager, private zone: Zone) {
1818
const monitor = this.manager.getMonitor();
1919
this.collector$ = new BehaviorSubject<DragLayerMonitor>(monitor);
2020
this.unsubscribeFromOffsetChange = monitor.subscribeToOffsetChange(

packages/core/src/internal/register-source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DragDropManager, DragSource } from 'dnd-core';
22

3-
export default function registerSource(type: any, source: DragSource, manager: DragDropManager<any>) {
3+
export default function registerSource(type: any, source: DragSource, manager: DragDropManager) {
44
const registry = manager.getRegistry();
55
const sourceId = registry.addSource(type, source);
66

packages/core/src/internal/register-target.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DragDropManager, DropTarget } from 'dnd-core';
22

3-
export default function registerTarget(type: any, target: DropTarget, manager: DragDropManager<any>) {
3+
export default function registerTarget(type: any, target: DropTarget, manager: DragDropManager) {
44
const registry = manager.getRegistry();
55
const targetId = registry.addTarget(type, target);
66

packages/core/src/tokens.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ export const DRAG_DROP_BACKEND = new InjectionToken<Backend>(
1111
'dnd-core compatible backend'
1212
);
1313

14+
/** The injection token for the dnd-core compatible backend's options. */
15+
export const DRAG_DROP_BACKEND_OPTIONS = new InjectionToken<any>(
16+
'options for dnd-core compatible backend'
17+
);
18+
19+
/** The injection token for the dnd-core compatible backend currently in use. */
20+
export const DRAG_DROP_BACKEND_DEBUG_MODE = new InjectionToken<any>(
21+
'should dnd-core run in debug mode?'
22+
);
23+
1424
/** The injection token for the dnd-core DragDropManager */
15-
export const DRAG_DROP_MANAGER = new InjectionToken<DragDropManager<any>>(
25+
export const DRAG_DROP_MANAGER = new InjectionToken<DragDropManager>(
1626
'dnd-core DragDropManager'
1727
);
1828

packages/examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"moment-mini-ts": "^2.20.1",
4040
"pressure": "^2.1.2",
4141
"react-dnd-mouse-backend": "^0.1.1",
42-
"react-dnd-test-backend": "^8.0.0",
42+
"react-dnd-test-backend": "^9.0.0",
4343
"rxjs": "^6.3.0",
4444
"zone.js": "~0.9.1"
4545
},

packages/examples/src/app/customMultiBackend.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ import { BackendTransition, TouchTransition } from 'dnd-multi-backend';
33
import { BackendFactory } from 'dnd-core';
44
import { default as HTML5Backend } from 'react-dnd-html5-backend';
55
import { default as TouchBackend } from 'react-dnd-touch-backend';
6+
import { TouchBackendOptions } from 'react-dnd-touch-backend/lib/interfaces';
67

78
const backendTransitions: BackendTransition[] = [
89
{
910
backend: HTML5Backend,
1011
transition: MouseTransition,
1112
},
1213
{
13-
backend: TouchBackend({
14+
backend: (manager, context) => TouchBackend(manager, context, {
1415
enableMouseEvents: false,
1516
ignoreContextMenu: true,
1617
delayTouchStart: 200, // milliseconds
17-
}) as BackendFactory,
18+
} as TouchBackendOptions),
19+
// backend: TouchBackend,
1820
transition: TouchTransition,
1921
preview: true,
2022
}

0 commit comments

Comments
 (0)