Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dnd-core

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dnd-core - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

.babelrc

901

dist-modules/__tests__/DragDropManager-test.js

@@ -1,31 +0,24 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var expect = _interopRequire(require("expect.js"));
var _expect = require('expect.js');
var Types = _interopRequire(require("./types"));
var _expect2 = _interopRequireWildcard(_expect);
var _sources = require("./sources");
var _Types = require('./types');
var NormalSource = _sources.NormalSource;
var NonDraggableSource = _sources.NonDraggableSource;
var BadItemSource = _sources.BadItemSource;
var _Types2 = _interopRequireWildcard(_Types);
var _targets = require("./targets");
var _NormalSource$NonDraggableSource$BadItemSource = require('./sources');
var NormalTarget = _targets.NormalTarget;
var NonDroppableTarget = _targets.NonDroppableTarget;
var TargetWithNoDropResult = _targets.TargetWithNoDropResult;
var BadResultTarget = _targets.BadResultTarget;
var TransformResultTarget = _targets.TransformResultTarget;
var _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget = require('./targets');
var _ = require("..");
var _DragDropManager$TestBackend = require('..');
var DragDropManager = _.DragDropManager;
var TestBackend = _.TestBackend;
var _isString = require('lodash/lang/isString');
var isString = _interopRequire(require("lodash/lang/isString"));
var _isString2 = _interopRequireWildcard(_isString);
describe("DragDropManager", function () {
describe('DragDropManager', function () {
var manager = undefined;

@@ -36,3 +29,3 @@ var backend = undefined;

beforeEach(function () {
manager = new DragDropManager(TestBackend);
manager = new _DragDropManager$TestBackend.DragDropManager(_DragDropManager$TestBackend.TestBackend);
backend = manager.getBackend();

@@ -42,11 +35,11 @@ registry = manager.getRegistry();

describe("handler registration", function () {
it("registers and unregisters drag sources", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
expect(registry.getSource(sourceId)).to.equal(source);
describe('handler registration', function () {
it('registers and unregisters drag sources', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
_expect2['default'](registry.getSource(sourceId)).to.equal(source);
registry.removeSource(sourceId);
expect(registry.getSource(sourceId)).to.equal(undefined);
expect(function () {
_expect2['default'](registry.getSource(sourceId)).to.equal(undefined);
_expect2['default'](function () {
return registry.removeSource(sourceId);

@@ -56,10 +49,10 @@ }).to.throwError();

it("registers and unregisters drop targets", function () {
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
expect(registry.getTarget(targetId)).to.equal(target);
it('registers and unregisters drop targets', function () {
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
_expect2['default'](registry.getTarget(targetId)).to.equal(target);
registry.removeTarget(targetId);
expect(registry.getTarget(targetId)).to.equal(undefined);
expect(function () {
_expect2['default'](registry.getTarget(targetId)).to.equal(undefined);
_expect2['default'](function () {
return registry.removeTarget(targetId);

@@ -69,10 +62,10 @@ }).to.throwError();

it("registers and unregisters multi-type drop targets", function () {
var target = new NormalTarget();
var targetId = registry.addTarget([Types.FOO, Types.BAR], target);
expect(registry.getTarget(targetId)).to.equal(target);
it('registers and unregisters multi-type drop targets', function () {
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget([_Types2['default'].FOO, _Types2['default'].BAR], target);
_expect2['default'](registry.getTarget(targetId)).to.equal(target);
registry.removeTarget(targetId);
expect(registry.getTarget(targetId)).to.equal(undefined);
expect(function () {
_expect2['default'](registry.getTarget(targetId)).to.equal(undefined);
_expect2['default'](function () {
return registry.removeTarget(targetId);

@@ -82,18 +75,18 @@ }).to.throwError();

it("knows the difference between sources and targets", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('knows the difference between sources and targets', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(function () {
_expect2['default'](function () {
return registry.getSource(targetId);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.getTarget(sourceId);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.removeSource(targetId);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.removeTarget(sourceId);

@@ -103,78 +96,78 @@ }).to.throwError();

it("throws on invalid type", function () {
var source = new NormalSource();
var target = new NormalTarget();
it('throws on invalid type', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
expect(function () {
_expect2['default'](function () {
return registry.addSource(null, source);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.addSource(undefined, source);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.addSource(23, source);
}).to.throwError();
expect(function () {
return registry.addSource(["yo"], source);
_expect2['default'](function () {
return registry.addSource(['yo'], source);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.addTarget(null, target);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.addTarget(undefined, target);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.addTarget(23, target);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.addTarget([23], target);
}).to.throwError();
expect(function () {
return registry.addTarget(["yo", null], target);
_expect2['default'](function () {
return registry.addTarget(['yo', null], target);
}).to.throwError();
expect(function () {
return registry.addTarget([["yo"]], target);
_expect2['default'](function () {
return registry.addTarget([['yo']], target);
}).to.throwError();
});
it("throws on adding the same source twice", function () {
var source = new NormalSource();
registry.addSource(Types.FOO, source);
it('throws on adding the same source twice', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
registry.addSource(_Types2['default'].FOO, source);
expect(function () {
return registry.addSource(Types.FOO, source);
_expect2['default'](function () {
return registry.addSource(_Types2['default'].FOO, source);
}).to.throwError();
expect(function () {
return registry.addSource(Types.BAR, source);
_expect2['default'](function () {
return registry.addSource(_Types2['default'].BAR, source);
}).to.throwError();
});
it("throws on adding the same target twice", function () {
var target = new NormalTarget();
registry.addTarget(Types.FOO, target);
it('throws on adding the same target twice', function () {
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
registry.addTarget(_Types2['default'].FOO, target);
expect(function () {
return registry.addTarget(Types.FOO, target);
_expect2['default'](function () {
return registry.addTarget(_Types2['default'].FOO, target);
}).to.throwError();
expect(function () {
return registry.addTarget(Types.BAR, target);
_expect2['default'](function () {
return registry.addTarget(_Types2['default'].BAR, target);
}).to.throwError();
expect(function () {
return registry.addTarget([Types.FOO, Types.BAR], target);
_expect2['default'](function () {
return registry.addTarget([_Types2['default'].FOO, _Types2['default'].BAR], target);
}).to.throwError();
});
it("calls setup() and teardown() on backend", function () {
expect(backend.didCallSetup).to.equal(undefined);
expect(backend.didCallTeardown).to.equal(undefined);
it('calls setup() and teardown() on backend', function () {
_expect2['default'](backend.didCallSetup).to.equal(undefined);
_expect2['default'](backend.didCallTeardown).to.equal(undefined);
var sourceId = registry.addSource(Types.FOO, new NormalSource());
expect(backend.didCallSetup).to.equal(true);
expect(backend.didCallTeardown).to.equal(undefined);
var sourceId = registry.addSource(_Types2['default'].FOO, new _NormalSource$NonDraggableSource$BadItemSource.NormalSource());
_expect2['default'](backend.didCallSetup).to.equal(true);
_expect2['default'](backend.didCallTeardown).to.equal(undefined);
backend.didCallSetup = undefined;
backend.didCallTeardown = undefined;
var targetId = registry.addTarget(Types.FOO, new NormalTarget());
expect(backend.didCallSetup).to.equal(undefined);
expect(backend.didCallTeardown).to.equal(undefined);
var targetId = registry.addTarget(_Types2['default'].FOO, new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget());
_expect2['default'](backend.didCallSetup).to.equal(undefined);
_expect2['default'](backend.didCallTeardown).to.equal(undefined);
backend.didCallSetup = undefined;

@@ -184,4 +177,4 @@ backend.didCallTeardown = undefined;

registry.removeSource(sourceId);
expect(backend.didCallSetup).to.equal(undefined);
expect(backend.didCallTeardown).to.equal(undefined);
_expect2['default'](backend.didCallSetup).to.equal(undefined);
_expect2['default'](backend.didCallTeardown).to.equal(undefined);
backend.didCallSetup = undefined;

@@ -191,46 +184,46 @@ backend.didCallTeardown = undefined;

registry.removeTarget(targetId);
expect(backend.didCallSetup).to.equal(undefined);
expect(backend.didCallTeardown).to.equal(true);
_expect2['default'](backend.didCallSetup).to.equal(undefined);
_expect2['default'](backend.didCallTeardown).to.equal(true);
backend.didCallSetup = undefined;
backend.didCallTeardown = undefined;
registry.addTarget(Types.BAR, new NormalTarget());
expect(backend.didCallSetup).to.equal(true);
expect(backend.didCallTeardown).to.equal(undefined);
registry.addTarget(_Types2['default'].BAR, new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget());
_expect2['default'](backend.didCallSetup).to.equal(true);
_expect2['default'](backend.didCallTeardown).to.equal(undefined);
});
it("returns string handles", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget([Types.FOO, Types.BAR], targetB);
it('returns string handles', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetBId = registry.addTarget([_Types2['default'].FOO, _Types2['default'].BAR], targetB);
expect(isString(sourceId)).to.equal(true);
expect(isString(targetAId)).to.equal(true);
expect(isString(targetBId)).to.equal(true);
_expect2['default'](_isString2['default'](sourceId)).to.equal(true);
_expect2['default'](_isString2['default'](targetAId)).to.equal(true);
_expect2['default'](_isString2['default'](targetBId)).to.equal(true);
});
it("accurately reports handler role", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('accurately reports handler role', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(registry.isSourceId(sourceId)).to.equal(true);
expect(registry.isSourceId(targetId)).to.equal(false);
expect(function () {
return registry.isSourceId("something else");
_expect2['default'](registry.isSourceId(sourceId)).to.equal(true);
_expect2['default'](registry.isSourceId(targetId)).to.equal(false);
_expect2['default'](function () {
return registry.isSourceId('something else');
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.isSourceId(null);
}).to.throwError();
expect(registry.isTargetId(sourceId)).to.equal(false);
expect(registry.isTargetId(targetId)).to.equal(true);
expect(function () {
return registry.isTargetId("something else");
_expect2['default'](registry.isTargetId(sourceId)).to.equal(false);
_expect2['default'](registry.isTargetId(targetId)).to.equal(true);
_expect2['default'](function () {
return registry.isTargetId('something else');
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return registry.isTargetId(null);

@@ -241,129 +234,161 @@ }).to.throwError();

describe("drag source and target contract", function () {
describe("beginDrag() and canDrag()", function () {
it("ignores beginDrag() if canDrag() returns false", function () {
var source = new NonDraggableSource();
var sourceId = registry.addSource(Types.FOO, source);
describe('drag source and target contract', function () {
describe('beginDrag() and canDrag()', function () {
it('ignores beginDrag() if canDrag() returns false', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NonDraggableSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag(sourceId);
expect(source.didCallBeginDrag).to.equal(false);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](source.didCallBeginDrag).to.equal(false);
});
it("throws if beginDrag() returns non-object", function () {
var source = new BadItemSource();
var sourceId = registry.addSource(Types.FOO, source);
it('throws if beginDrag() returns non-object', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.BadItemSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
expect(function () {
return backend.simulateBeginDrag(sourceId);
_expect2['default'](function () {
return backend.simulateBeginDrag([sourceId]);
}).to.throwError();
});
it("begins drag if canDrag() returns true", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('begins drag if canDrag() returns true', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag(sourceId);
expect(source.didCallBeginDrag).to.equal(true);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](source.didCallBeginDrag).to.equal(true);
});
it("throws in beginDrag() if it is called twice during one operation", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('throws in beginDrag() if it is called twice during one operation', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag(sourceId);
expect(function () {
return backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateBeginDrag([sourceId]);
}).to.throwError();
});
it("throws in beginDrag() if it is called with an invalid handle", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('throws in beginDrag() if it is called with an invalid handles', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(function () {
_expect2['default'](function () {
return backend.simulateBeginDrag('yo');
}).to.throwError();
_expect2['default'](function () {
return backend.simulateBeginDrag(null);
}).to.throwError();
expect(function () {
return backend.simulateBeginDrag("yo");
_expect2['default'](function () {
return backend.simulateBeginDrag(sourceId);
}).to.throwError();
expect(function () {
return backend.simulateBeginDrag(targetId);
_expect2['default'](function () {
return backend.simulateBeginDrag([null]);
}).to.throwError();
_expect2['default'](function () {
return backend.simulateBeginDrag(['yo']);
}).to.throwError();
_expect2['default'](function () {
return backend.simulateBeginDrag([targetId]);
}).to.throwError();
_expect2['default'](function () {
return backend.simulateBeginDrag([null, sourceId]);
}).to.throwError();
_expect2['default'](function () {
return backend.simulateBeginDrag([targetId, sourceId]);
}).to.throwError();
registry.removeSource(sourceId);
expect(function () {
return backend.simulateBeginDrag(sourceId);
_expect2['default'](function () {
return backend.simulateBeginDrag([sourceId]);
}).to.throwError();
});
it("lets beginDrag() be called again in a next operation", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('calls beginDrag() on the innermost handler with canDrag() returning true', function () {
var sourceA = new _NormalSource$NonDraggableSource$BadItemSource.NonDraggableSource();
var sourceAId = registry.addSource(_Types2['default'].FOO, sourceA);
var sourceB = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceBId = registry.addSource(_Types2['default'].FOO, sourceB);
var sourceC = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceCId = registry.addSource(_Types2['default'].FOO, sourceC);
var sourceD = new _NormalSource$NonDraggableSource$BadItemSource.NonDraggableSource();
var sourceDId = registry.addSource(_Types2['default'].FOO, sourceD);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceAId, sourceBId, sourceCId, sourceDId]);
_expect2['default'](sourceA.didCallBeginDrag).to.equal(false);
_expect2['default'](sourceB.didCallBeginDrag).to.equal(false);
_expect2['default'](sourceC.didCallBeginDrag).to.equal(true);
_expect2['default'](sourceD.didCallBeginDrag).to.equal(false);
});
it('lets beginDrag() be called again in a next operation', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag([sourceId]);
backend.simulateEndDrag(sourceId);
source.didCallBeginDrag = false;
expect(function () {
return backend.simulateBeginDrag(sourceId);
_expect2['default'](function () {
return backend.simulateBeginDrag([sourceId]);
}).to.not.throwError();
expect(source.didCallBeginDrag).to.equal(true);
_expect2['default'](source.didCallBeginDrag).to.equal(true);
});
});
describe("drop(), canDrop() and endDrag()", function () {
it("endDrag() sees drop() return value as drop result if dropped on a target", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
describe('drop(), canDrop() and endDrag()', function () {
it('endDrag() sees drop() return value as drop result if dropped on a target', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(target.didCallDrop).to.equal(true);
expect(source.recordedDropResult.foo).to.equal("bar");
_expect2['default'](target.didCallDrop).to.equal(true);
_expect2['default'](source.recordedDropResult.foo).to.equal('bar');
});
it("endDrag() sees true as drop result by default if dropped on a target", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new TargetWithNoDropResult();
var targetId = registry.addTarget(Types.FOO, target);
it('endDrag() sees true as drop result by default if dropped on a target', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(source.recordedDropResult).to.equal(true);
_expect2['default'](source.recordedDropResult).to.equal(true);
});
it("endDrag() sees false as drop result if dropped outside a target", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('endDrag() sees false as drop result if dropped outside a target', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateEndDrag();
expect(source.recordedDropResult).to.equal(false);
_expect2['default'](source.recordedDropResult).to.equal(false);
});
it("calls endDrag even if source was unregistered", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('calls endDrag even if source was unregistered', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
registry.removeSource(sourceId);
expect(registry.getSource(sourceId)).to.equal(undefined);
_expect2['default'](registry.getSource(sourceId)).to.equal(undefined);
backend.simulateEndDrag();
expect(source.recordedDropResult).to.equal(false);
_expect2['default'](source.recordedDropResult).to.equal(false);
});
it("throws in endDrag() if it is called outside a drag operation", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
expect(function () {
it('throws in endDrag() if it is called outside a drag operation', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
_expect2['default'](function () {
return backend.simulateEndDrag(sourceId);

@@ -373,21 +398,21 @@ }).to.throwError();

it("ignores drop() if no drop targets entered", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('ignores drop() if no drop targets entered', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(source.recordedDropResult).to.equal(false);
_expect2['default'](source.recordedDropResult).to.equal(false);
});
it("ignores drop() if drop targets entered and left", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
it('ignores drop() if drop targets entered and left', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId]);

@@ -399,33 +424,33 @@ backend.simulateHover([targetAId, targetBId]);

backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(false);
expect(targetB.didCallDrop).to.equal(false);
expect(source.recordedDropResult).to.equal(false);
_expect2['default'](targetA.didCallDrop).to.equal(false);
_expect2['default'](targetB.didCallDrop).to.equal(false);
_expect2['default'](source.recordedDropResult).to.equal(false);
});
it("ignores drop() if canDrop() returns false", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NonDroppableTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('ignores drop() if canDrop() returns false', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NonDroppableTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
backend.simulateDrop();
expect(target.didCallDrop).to.equal(false);
_expect2['default'](target.didCallDrop).to.equal(false);
});
it("ignores drop() if target has a different type", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.BAR, target);
it('ignores drop() if target has a different type', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].BAR, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
backend.simulateDrop();
expect(target.didCallDrop).to.equal(false);
_expect2['default'](target.didCallDrop).to.equal(false);
});
it("throws in drop() if it is called outside a drag operation", function () {
expect(function () {
it('throws in drop() if it is called outside a drag operation', function () {
_expect2['default'](function () {
return backend.simulateDrop();

@@ -435,11 +460,11 @@ }).to.throwError();

it("throws in drop() if it returns something that is neither undefined nor an object", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new BadResultTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('throws in drop() if it returns something that is neither undefined nor an object', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.BadResultTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
expect(function () {
_expect2['default'](function () {
return backend.simulateDrop();

@@ -449,150 +474,150 @@ }).to.throwError();

describe("nested drop targets", function () {
it("uses child result if parents have no drop result", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new TargetWithNoDropResult();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget({ number: 16 });
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NormalTarget({ number: 42 });
var targetCId = registry.addTarget(Types.FOO, targetC);
describe('nested drop targets', function () {
it('uses child result if parents have no drop result', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 16 });
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 42 });
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(true);
expect(targetB.didCallDrop).to.equal(true);
expect(targetC.didCallDrop).to.equal(true);
expect(source.recordedDropResult.number).to.equal(16);
_expect2['default'](targetA.didCallDrop).to.equal(true);
_expect2['default'](targetB.didCallDrop).to.equal(true);
_expect2['default'](targetC.didCallDrop).to.equal(true);
_expect2['default'](source.recordedDropResult.number).to.equal(16);
});
it("excludes targets of different type when dispatching drop", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new TargetWithNoDropResult();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget({ number: 16 });
var targetBId = registry.addTarget(Types.BAR, targetB);
var targetC = new NormalTarget({ number: 42 });
var targetCId = registry.addTarget(Types.FOO, targetC);
it('excludes targets of different type when dispatching drop', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 16 });
var targetBId = registry.addTarget(_Types2['default'].BAR, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 42 });
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(true);
expect(targetB.didCallDrop).to.equal(false);
expect(targetC.didCallDrop).to.equal(true);
expect(source.recordedDropResult.number).to.equal(42);
_expect2['default'](targetA.didCallDrop).to.equal(true);
_expect2['default'](targetB.didCallDrop).to.equal(false);
_expect2['default'](targetC.didCallDrop).to.equal(true);
_expect2['default'](source.recordedDropResult.number).to.equal(42);
});
it("excludes non-droppable targets when dispatching drop", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new TargetWithNoDropResult();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new TargetWithNoDropResult();
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NonDroppableTarget({ number: 16 });
var targetCId = registry.addTarget(Types.BAR, targetC);
it('excludes non-droppable targets when dispatching drop', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NonDroppableTarget({ number: 16 });
var targetCId = registry.addTarget(_Types2['default'].BAR, targetC);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(true);
expect(targetB.didCallDrop).to.equal(true);
expect(targetC.didCallDrop).to.equal(false);
expect(source.recordedDropResult).to.equal(true);
_expect2['default'](targetA.didCallDrop).to.equal(true);
_expect2['default'](targetB.didCallDrop).to.equal(true);
_expect2['default'](targetC.didCallDrop).to.equal(false);
_expect2['default'](source.recordedDropResult).to.equal(true);
});
it("lets parent drop targets transform child results", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new TargetWithNoDropResult();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new TransformResultTarget(function (dropResult) {
it('lets parent drop targets transform child results', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TransformResultTarget(function (dropResult) {
return { number: dropResult.number * 2 };
});
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NonDroppableTarget();
var targetCId = registry.addTarget(Types.FOO, targetC);
var targetD = new TransformResultTarget(function (dropResult) {
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NonDroppableTarget();
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
var targetD = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TransformResultTarget(function (dropResult) {
return { number: dropResult.number + 1 };
});
var targetDId = registry.addTarget(Types.FOO, targetD);
var targetE = new NormalTarget({ number: 42 });
var targetEId = registry.addTarget(Types.FOO, targetE);
var targetF = new TransformResultTarget(function (dropResult) {
var targetDId = registry.addTarget(_Types2['default'].FOO, targetD);
var targetE = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 42 });
var targetEId = registry.addTarget(_Types2['default'].FOO, targetE);
var targetF = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TransformResultTarget(function (dropResult) {
return { number: dropResult.number / 2 };
});
var targetFId = registry.addTarget(Types.BAR, targetF);
var targetG = new NormalTarget({ number: 100 });
var targetGId = registry.addTarget(Types.BAR, targetG);
var targetFId = registry.addTarget(_Types2['default'].BAR, targetF);
var targetG = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 100 });
var targetGId = registry.addTarget(_Types2['default'].BAR, targetG);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId, targetDId, targetEId, targetFId, targetGId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(true);
expect(targetB.didCallDrop).to.equal(true);
expect(targetC.didCallDrop).to.equal(false);
expect(targetD.didCallDrop).to.equal(true);
expect(targetE.didCallDrop).to.equal(true);
expect(targetF.didCallDrop).to.equal(false);
expect(targetG.didCallDrop).to.equal(false);
expect(source.recordedDropResult.number).to.equal((42 + 1) * 2);
_expect2['default'](targetA.didCallDrop).to.equal(true);
_expect2['default'](targetB.didCallDrop).to.equal(true);
_expect2['default'](targetC.didCallDrop).to.equal(false);
_expect2['default'](targetD.didCallDrop).to.equal(true);
_expect2['default'](targetE.didCallDrop).to.equal(true);
_expect2['default'](targetF.didCallDrop).to.equal(false);
_expect2['default'](targetG.didCallDrop).to.equal(false);
_expect2['default'](source.recordedDropResult.number).to.equal((42 + 1) * 2);
});
it("always chooses parent drop result", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget({ number: 12345 });
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new TransformResultTarget(function (dropResult) {
it('always chooses parent drop result', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 12345 });
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TransformResultTarget(function (dropResult) {
return { number: dropResult.number * 2 };
});
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NonDroppableTarget();
var targetCId = registry.addTarget(Types.FOO, targetC);
var targetD = new TransformResultTarget(function (dropResult) {
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NonDroppableTarget();
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
var targetD = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TransformResultTarget(function (dropResult) {
return { number: dropResult.number + 1 };
});
var targetDId = registry.addTarget(Types.FOO, targetD);
var targetE = new NormalTarget({ number: 42 });
var targetEId = registry.addTarget(Types.FOO, targetE);
var targetF = new TransformResultTarget(function (dropResult) {
var targetDId = registry.addTarget(_Types2['default'].FOO, targetD);
var targetE = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 42 });
var targetEId = registry.addTarget(_Types2['default'].FOO, targetE);
var targetF = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TransformResultTarget(function (dropResult) {
return { number: dropResult.number / 2 };
});
var targetFId = registry.addTarget(Types.BAR, targetF);
var targetG = new NormalTarget({ number: 100 });
var targetGId = registry.addTarget(Types.BAR, targetG);
var targetFId = registry.addTarget(_Types2['default'].BAR, targetF);
var targetG = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget({ number: 100 });
var targetGId = registry.addTarget(_Types2['default'].BAR, targetG);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId, targetDId, targetEId, targetFId, targetGId]);
backend.simulateDrop();
backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(true);
expect(targetB.didCallDrop).to.equal(true);
expect(targetC.didCallDrop).to.equal(false);
expect(targetD.didCallDrop).to.equal(true);
expect(targetE.didCallDrop).to.equal(true);
expect(targetF.didCallDrop).to.equal(false);
expect(targetG.didCallDrop).to.equal(false);
expect(source.recordedDropResult.number).to.equal(12345);
_expect2['default'](targetA.didCallDrop).to.equal(true);
_expect2['default'](targetB.didCallDrop).to.equal(true);
_expect2['default'](targetC.didCallDrop).to.equal(false);
_expect2['default'](targetD.didCallDrop).to.equal(true);
_expect2['default'](targetE.didCallDrop).to.equal(true);
_expect2['default'](targetF.didCallDrop).to.equal(false);
_expect2['default'](targetG.didCallDrop).to.equal(false);
_expect2['default'](source.recordedDropResult.number).to.equal(12345);
});
it("excludes removed targets when dispatching drop", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NormalTarget();
var targetCId = registry.addTarget(Types.FOO, targetC);
it('excludes removed targets when dispatching drop', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId]);

@@ -602,5 +627,5 @@ registry.removeTarget(targetBId);

backend.simulateEndDrag();
expect(targetA.didCallDrop).to.equal(true);
expect(targetB.didCallDrop).to.equal(false);
expect(targetC.didCallDrop).to.equal(true);
_expect2['default'](targetA.didCallDrop).to.equal(true);
_expect2['default'](targetB.didCallDrop).to.equal(false);
_expect2['default'](targetC.didCallDrop).to.equal(true);
});

@@ -610,15 +635,15 @@ });

describe("hover()", function () {
it("lets hover() be called any time", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.BAR, target);
describe('hover()', function () {
it('lets hover() be called any time', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].BAR, target);
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetId]);
}).to.not.throwError();
backend.simulateBeginDrag(sourceId);
expect(function () {
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateHover([targetId]);

@@ -628,3 +653,3 @@ }).to.not.throwError();

backend.simulateDrop();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetId]);

@@ -634,8 +659,8 @@ }).to.not.throwError();

backend.simulateEndDrag();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetId]);
}).to.not.throwError();
backend.simulateBeginDrag(sourceId);
expect(function () {
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateHover([targetId]);

@@ -645,18 +670,18 @@ }).to.not.throwError();

it("does not call hover() outside drag operation", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('does not call hover() outside drag operation', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
backend.simulateHover([targetId]);
expect(target.didCallHover).to.equal(false);
_expect2['default'](target.didCallHover).to.equal(false);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
expect(target.didCallHover).to.equal(true);
_expect2['default'](target.didCallHover).to.equal(true);
target.didCallHover = false;
backend.simulateHover([targetId]);
expect(target.didCallHover).to.equal(true);
_expect2['default'](target.didCallHover).to.equal(true);

@@ -666,49 +691,49 @@ target.didCallHover = false;

backend.simulateHover([targetId]);
expect(target.didCallHover).to.equal(false);
_expect2['default'](target.didCallHover).to.equal(false);
});
it("excludes targets of different type when dispatching hover", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.BAR, targetB);
var targetC = new NormalTarget();
var targetCId = registry.addTarget(Types.FOO, targetC);
var targetD = new NormalTarget();
var targetDId = registry.addTarget([Types.BAZ, Types.FOO], targetD);
it('excludes targets of different type when dispatching hover', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].BAR, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
var targetD = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetDId = registry.addTarget([_Types2['default'].BAZ, _Types2['default'].FOO], targetD);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId, targetCId, targetDId]);
expect(targetA.didCallHover).to.equal(true);
expect(targetB.didCallHover).to.equal(false);
expect(targetC.didCallHover).to.equal(true);
expect(targetD.didCallHover).to.equal(true);
_expect2['default'](targetA.didCallHover).to.equal(true);
_expect2['default'](targetB.didCallHover).to.equal(false);
_expect2['default'](targetC.didCallHover).to.equal(true);
_expect2['default'](targetD.didCallHover).to.equal(true);
});
it("includes non-droppable targets when dispatching hover", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new TargetWithNoDropResult();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new TargetWithNoDropResult();
var targetBId = registry.addTarget(Types.FOO, targetB);
it('includes non-droppable targets when dispatching hover', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.TargetWithNoDropResult();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetAId, targetBId]);
expect(targetA.didCallHover).to.equal(true);
expect(targetB.didCallHover).to.equal(true);
_expect2['default'](targetA.didCallHover).to.equal(true);
_expect2['default'](targetB.didCallHover).to.equal(true);
});
it("throws in hover() if it contains the same target twice", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.BAR, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.BAR, targetB);
it('throws in hover() if it contains the same target twice', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].BAR, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].BAR, targetB);
backend.simulateBeginDrag(sourceId);
expect(function () {
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateHover([targetAId, targetBId, targetAId]);

@@ -718,16 +743,16 @@ }).to.throwError();

it("throws in hover() if it is called with a non-array", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.BAR, target);
it('throws in hover() if it is called with a non-array', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].BAR, target);
backend.simulateBeginDrag(sourceId);
expect(function () {
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateHover(null);
}).to.throwError();
expect(function () {
return backend.simulateHover("yo");
_expect2['default'](function () {
return backend.simulateHover('yo');
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover(targetId);

@@ -737,16 +762,16 @@ }).to.throwError();

it("throws in hover() if it contains an invalid drop target", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.BAR, target);
it('throws in hover() if it contains an invalid drop target', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].BAR, target);
backend.simulateBeginDrag(sourceId);
expect(function () {
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateHover([targetId, null]);
}).to.throwError();
expect(function () {
return backend.simulateHover([targetId, "yo"]);
_expect2['default'](function () {
return backend.simulateHover([targetId, 'yo']);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetId, sourceId]);

@@ -756,12 +781,12 @@ }).to.throwError();

it("throws in hover() if it contains a removed drop target", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.BAR, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
it('throws in hover() if it contains a removed drop target', function () {
var source = new _NormalSource$NonDraggableSource$BadItemSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].BAR, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult$BadResultTarget$TransformResultTarget.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
backend.simulateBeginDrag(sourceId);
expect(function () {
backend.simulateBeginDrag([sourceId]);
_expect2['default'](function () {
return backend.simulateHover([targetAId, targetBId]);

@@ -772,9 +797,9 @@ }).to.not.throwError();

registry.removeTarget(targetAId);
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetBId, targetAId]);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetAId, targetBId]);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetBId]);

@@ -785,14 +810,14 @@ }).to.not.throwError();

registry.removeTarget(targetBId);
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetBId, targetAId]);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetBId]);
}).to.throwError();
expect(function () {
_expect2['default'](function () {
return backend.simulateHover([targetAId]);
}).to.throwError();
targetAId = registry.addTarget(Types.FOO, targetA);
expect(function () {
targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
_expect2['default'](function () {
return backend.simulateHover([targetAId]);

@@ -802,4 +827,4 @@ }).to.not.throwError();

backend.simulateHover([targetAId]);
targetBId = registry.addTarget(Types.BAR, targetB);
expect(function () {
targetBId = registry.addTarget(_Types2['default'].BAR, targetB);
_expect2['default'](function () {
return backend.simulateHover([targetAId, targetBId]);

@@ -806,0 +831,0 @@ }).to.not.throwError();

@@ -1,27 +0,20 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var expect = _interopRequire(require("expect.js"));
var _expect = require('expect.js');
var Types = _interopRequire(require("./types"));
var _expect2 = _interopRequireWildcard(_expect);
var _sources = require("./sources");
var _Types = require('./types');
var NormalSource = _sources.NormalSource;
var NonDraggableSource = _sources.NonDraggableSource;
var NumberSource = _sources.NumberSource;
var _Types2 = _interopRequireWildcard(_Types);
var _targets = require("./targets");
var _NormalSource$NonDraggableSource$NumberSource = require('./sources');
var NormalTarget = _targets.NormalTarget;
var NonDroppableTarget = _targets.NonDroppableTarget;
var TargetWithNoDropResult = _targets.TargetWithNoDropResult;
var _NormalTarget$NonDroppableTarget$TargetWithNoDropResult = require('./targets');
var _ = require("..");
var _DragDropManager$TestBackend = require('..');
var DragDropManager = _.DragDropManager;
var TestBackend = _.TestBackend;
describe("DragDropMonitor", function () {
describe('DragDropMonitor', function () {
var manager = undefined;

@@ -33,3 +26,3 @@ var backend = undefined;

beforeEach(function () {
manager = new DragDropManager(TestBackend);
manager = new _DragDropManager$TestBackend.DragDropManager(_DragDropManager$TestBackend.TestBackend);
backend = manager.getBackend();

@@ -40,18 +33,18 @@ registry = manager.getRegistry();

describe("change event", function () {
it("raises change event on beginDrag()", function (done) {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
describe('change event', function () {
it('raises change event on beginDrag()', function (done) {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
monitor.addChangeListener(done);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
});
it("raises change event on endDrag()", function (done) {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
registry.addTarget(Types.FOO, target);
it('raises change event on endDrag()', function (done) {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
registry.addTarget(_Types2['default'].FOO, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
monitor.addChangeListener(done);

@@ -61,9 +54,9 @@ backend.simulateEndDrag();

it("does not raise change event if hover targets have not changed", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget({ a: 123 });
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new TargetWithNoDropResult();
var targetBId = registry.addTarget(Types.FOO, targetB);
it('does not raise change event if hover targets have not changed', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget({ a: 123 });
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.TargetWithNoDropResult();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);

@@ -77,405 +70,405 @@ var raisedChange = false;

backend.simulateBeginDrag(sourceId);
expect(raisedChange).to.equal(true);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](raisedChange).to.equal(true);
raisedChange = false;
backend.simulateHover([targetAId]);
expect(raisedChange).to.equal(true);
_expect2['default'](raisedChange).to.equal(true);
raisedChange = false;
backend.simulateHover([targetBId]);
expect(raisedChange).to.equal(true);
_expect2['default'](raisedChange).to.equal(true);
raisedChange = false;
backend.simulateHover([targetBId]);
expect(raisedChange).to.equal(false);
_expect2['default'](raisedChange).to.equal(false);
backend.simulateHover([targetBId, targetAId]);
expect(raisedChange).to.equal(true);
_expect2['default'](raisedChange).to.equal(true);
raisedChange = false;
backend.simulateHover([targetBId, targetAId]);
expect(raisedChange).to.equal(false);
_expect2['default'](raisedChange).to.equal(false);
backend.simulateHover([targetAId, targetBId]);
expect(raisedChange).to.equal(true);
_expect2['default'](raisedChange).to.equal(true);
raisedChange = false;
backend.simulateHover([targetAId, targetBId]);
expect(raisedChange).to.equal(false);
_expect2['default'](raisedChange).to.equal(false);
});
});
describe("state tracking", function () {
it("returns true from canDrag unless already dragging or drag source opts out", function () {
var sourceA = new NormalSource();
var sourceAId = registry.addSource(Types.FOO, sourceA);
var sourceB = new NormalSource();
var sourceBId = registry.addSource(Types.FOO, sourceB);
var sourceC = new NormalSource();
var sourceCId = registry.addSource(Types.BAR, sourceC);
var sourceD = new NonDraggableSource();
var sourceDId = registry.addSource(Types.FOO, sourceD);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
describe('state tracking', function () {
it('returns true from canDrag unless already dragging or drag source opts out', function () {
var sourceA = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceAId = registry.addSource(_Types2['default'].FOO, sourceA);
var sourceB = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceBId = registry.addSource(_Types2['default'].FOO, sourceB);
var sourceC = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceCId = registry.addSource(_Types2['default'].BAR, sourceC);
var sourceD = new _NormalSource$NonDraggableSource$NumberSource.NonDraggableSource();
var sourceDId = registry.addSource(_Types2['default'].FOO, sourceD);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(monitor.canDrag(sourceAId)).to.equal(true);
expect(monitor.canDrag(sourceBId)).to.equal(true);
expect(monitor.canDrag(sourceCId)).to.equal(true);
expect(monitor.canDrag(sourceDId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceAId)).to.equal(true);
_expect2['default'](monitor.canDrag(sourceBId)).to.equal(true);
_expect2['default'](monitor.canDrag(sourceCId)).to.equal(true);
_expect2['default'](monitor.canDrag(sourceDId)).to.equal(false);
backend.simulateBeginDrag(sourceAId);
expect(monitor.canDrag(sourceAId)).to.equal(false);
expect(monitor.canDrag(sourceBId)).to.equal(false);
expect(monitor.canDrag(sourceCId)).to.equal(false);
expect(monitor.canDrag(sourceDId)).to.equal(false);
backend.simulateBeginDrag([sourceAId]);
_expect2['default'](monitor.canDrag(sourceAId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceBId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceCId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceDId)).to.equal(false);
backend.simulateHover([targetId]);
backend.simulateDrop();
expect(monitor.canDrag(sourceAId)).to.equal(false);
expect(monitor.canDrag(sourceBId)).to.equal(false);
expect(monitor.canDrag(sourceCId)).to.equal(false);
expect(monitor.canDrag(sourceDId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceAId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceBId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceCId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceDId)).to.equal(false);
backend.simulateEndDrag();
expect(monitor.canDrag(sourceAId)).to.equal(true);
expect(monitor.canDrag(sourceBId)).to.equal(true);
expect(monitor.canDrag(sourceCId)).to.equal(true);
expect(monitor.canDrag(sourceDId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceAId)).to.equal(true);
_expect2['default'](monitor.canDrag(sourceBId)).to.equal(true);
_expect2['default'](monitor.canDrag(sourceCId)).to.equal(true);
_expect2['default'](monitor.canDrag(sourceDId)).to.equal(false);
backend.simulateBeginDrag(sourceAId);
expect(monitor.canDrag(sourceAId)).to.equal(false);
expect(monitor.canDrag(sourceBId)).to.equal(false);
expect(monitor.canDrag(sourceCId)).to.equal(false);
expect(monitor.canDrag(sourceDId)).to.equal(false);
backend.simulateBeginDrag([sourceAId]);
_expect2['default'](monitor.canDrag(sourceAId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceBId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceCId)).to.equal(false);
_expect2['default'](monitor.canDrag(sourceDId)).to.equal(false);
});
it("returns true from canDrop if dragging and type matches, unless target opts out", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NormalTarget();
var targetCId = registry.addTarget(Types.BAR, targetC);
var targetD = new NonDroppableTarget();
var targetDId = registry.addTarget(Types.FOO, targetD);
it('returns true from canDrop if dragging and type matches, unless target opts out', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetCId = registry.addTarget(_Types2['default'].BAR, targetC);
var targetD = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NonDroppableTarget();
var targetDId = registry.addTarget(_Types2['default'].FOO, targetD);
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(false);
expect(monitor.canDrop(targetDId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetDId)).to.equal(false);
backend.simulateBeginDrag(sourceId);
expect(monitor.canDrop(targetAId)).to.equal(true);
expect(monitor.canDrop(targetBId)).to.equal(true);
expect(monitor.canDrop(targetCId)).to.equal(false);
expect(monitor.canDrop(targetDId)).to.equal(false);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(true);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(true);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetDId)).to.equal(false);
backend.simulateHover([targetAId]);
backend.simulateDrop();
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(false);
expect(monitor.canDrop(targetDId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetDId)).to.equal(false);
backend.simulateEndDrag();
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(false);
expect(monitor.canDrop(targetDId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetDId)).to.equal(false);
backend.simulateBeginDrag(sourceId);
expect(monitor.canDrop(targetAId)).to.equal(true);
expect(monitor.canDrop(targetBId)).to.equal(true);
expect(monitor.canDrop(targetCId)).to.equal(false);
expect(monitor.canDrop(targetDId)).to.equal(false);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(true);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(true);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetDId)).to.equal(false);
});
it("returns true from isDragging only while dragging", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var other = new NormalSource();
var otherId = registry.addSource(Types.FOO, other);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('returns true from isDragging only while dragging', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var other = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var otherId = registry.addSource(_Types2['default'].FOO, other);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
expect(monitor.isDragging(otherId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging(otherId)).to.equal(false);
backend.simulateBeginDrag(sourceId);
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(true);
expect(monitor.isDragging(otherId)).to.equal(false);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(true);
_expect2['default'](monitor.isDragging(otherId)).to.equal(false);
backend.simulateHover([targetId]);
backend.simulateDrop();
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(true);
expect(monitor.isDragging(otherId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(true);
_expect2['default'](monitor.isDragging(otherId)).to.equal(false);
backend.simulateEndDrag();
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
expect(monitor.isDragging(otherId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging(otherId)).to.equal(false);
backend.simulateBeginDrag(otherId);
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(false);
expect(monitor.isDragging(otherId)).to.equal(true);
backend.simulateBeginDrag([otherId]);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging(otherId)).to.equal(true);
});
it("keeps track of dragged item, type and source handle", function () {
var sourceA = new NormalSource({ a: 123 });
var sourceAId = registry.addSource(Types.FOO, sourceA);
var sourceB = new NormalSource({ a: 456 });
var sourceBId = registry.addSource(Types.BAR, sourceB);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('keeps track of dragged item, type and source handle', function () {
var sourceA = new _NormalSource$NonDraggableSource$NumberSource.NormalSource({ a: 123 });
var sourceAId = registry.addSource(_Types2['default'].FOO, sourceA);
var sourceB = new _NormalSource$NonDraggableSource$NumberSource.NormalSource({ a: 456 });
var sourceBId = registry.addSource(_Types2['default'].BAR, sourceB);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(monitor.getItem()).to.equal(null);
expect(monitor.getItemType()).to.equal(null);
expect(monitor.getSourceId()).to.equal(null);
_expect2['default'](monitor.getItem()).to.equal(null);
_expect2['default'](monitor.getItemType()).to.equal(null);
_expect2['default'](monitor.getSourceId()).to.equal(null);
backend.simulateBeginDrag(sourceAId);
expect(monitor.getItem().a).to.equal(123);
expect(monitor.getItemType()).to.equal(Types.FOO);
expect(monitor.getSourceId()).to.equal(sourceAId);
backend.simulateBeginDrag([sourceAId]);
_expect2['default'](monitor.getItem().a).to.equal(123);
_expect2['default'](monitor.getItemType()).to.equal(_Types2['default'].FOO);
_expect2['default'](monitor.getSourceId()).to.equal(sourceAId);
backend.simulateHover([targetId]);
backend.simulateDrop();
expect(monitor.getItem().a).to.equal(123);
expect(monitor.getItemType()).to.equal(Types.FOO);
expect(monitor.getSourceId()).to.equal(sourceAId);
_expect2['default'](monitor.getItem().a).to.equal(123);
_expect2['default'](monitor.getItemType()).to.equal(_Types2['default'].FOO);
_expect2['default'](monitor.getSourceId()).to.equal(sourceAId);
backend.simulateEndDrag();
expect(monitor.getItem()).to.equal(null);
expect(monitor.getItemType()).to.equal(null);
expect(monitor.getSourceId()).to.equal(null);
_expect2['default'](monitor.getItem()).to.equal(null);
_expect2['default'](monitor.getItemType()).to.equal(null);
_expect2['default'](monitor.getSourceId()).to.equal(null);
backend.simulateBeginDrag(sourceBId);
backend.simulateBeginDrag([sourceBId]);
registry.removeSource(sourceBId);
expect(monitor.getItem().a).to.equal(456);
expect(monitor.getItemType()).to.equal(Types.BAR);
expect(monitor.getSourceId()).to.equal(sourceBId);
_expect2['default'](monitor.getItem().a).to.equal(456);
_expect2['default'](monitor.getItemType()).to.equal(_Types2['default'].BAR);
_expect2['default'](monitor.getSourceId()).to.equal(sourceBId);
});
it("keeps track of drop result and whether it occured", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget({ a: 123 });
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new TargetWithNoDropResult();
var targetBId = registry.addTarget(Types.FOO, targetB);
it('keeps track of drop result and whether it occured', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget({ a: 123 });
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.TargetWithNoDropResult();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
expect(monitor.didDrop()).to.equal(false);
expect(monitor.getDropResult()).to.equal(null);
_expect2['default'](monitor.didDrop()).to.equal(false);
_expect2['default'](monitor.getDropResult()).to.equal(null);
backend.simulateBeginDrag(sourceId);
expect(monitor.didDrop()).to.equal(false);
expect(monitor.getDropResult()).to.equal(false);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.didDrop()).to.equal(false);
_expect2['default'](monitor.getDropResult()).to.equal(false);
backend.simulateHover([targetAId]);
backend.simulateDrop();
expect(monitor.didDrop()).to.equal(true);
expect(monitor.getDropResult().a).to.equal(123);
_expect2['default'](monitor.didDrop()).to.equal(true);
_expect2['default'](monitor.getDropResult().a).to.equal(123);
backend.simulateEndDrag();
expect(monitor.didDrop()).to.equal(false);
expect(monitor.getDropResult()).to.equal(null);
_expect2['default'](monitor.didDrop()).to.equal(false);
_expect2['default'](monitor.getDropResult()).to.equal(null);
backend.simulateBeginDrag(sourceId);
expect(monitor.didDrop()).to.equal(false);
expect(monitor.getDropResult()).to.equal(false);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.didDrop()).to.equal(false);
_expect2['default'](monitor.getDropResult()).to.equal(false);
backend.simulateHover([targetBId]);
backend.simulateDrop();
expect(monitor.didDrop()).to.equal(true);
expect(monitor.getDropResult()).to.equal(true);
_expect2['default'](monitor.didDrop()).to.equal(true);
_expect2['default'](monitor.getDropResult()).to.equal(true);
backend.simulateEndDrag();
expect(monitor.didDrop()).to.equal(false);
expect(monitor.getDropResult()).to.equal(null);
_expect2['default'](monitor.didDrop()).to.equal(false);
_expect2['default'](monitor.getDropResult()).to.equal(null);
});
});
describe("multi-type targets", function () {
it("takes all types into consideration", function () {
var sourceA = new NormalSource();
var sourceAId = registry.addSource(Types.FOO, sourceA);
var sourceB = new NormalSource();
var sourceBId = registry.addSource(Types.BAZ, sourceB);
var targetA = new NormalTarget();
var targetAId = registry.addTarget([Types.FOO, Types.BAR], targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget([Types.BAR, Types.BAZ], targetB);
var targetC = new NormalTarget();
var targetCId = registry.addTarget([Types.FOO, Types.BAR, Types.BAZ], targetC);
describe('multi-type targets', function () {
it('takes all types into consideration', function () {
var sourceA = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceAId = registry.addSource(_Types2['default'].FOO, sourceA);
var sourceB = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceBId = registry.addSource(_Types2['default'].BAZ, sourceB);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetAId = registry.addTarget([_Types2['default'].FOO, _Types2['default'].BAR], targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetBId = registry.addTarget([_Types2['default'].BAR, _Types2['default'].BAZ], targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetCId = registry.addTarget([_Types2['default'].FOO, _Types2['default'].BAR, _Types2['default'].BAZ], targetC);
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
backend.simulateBeginDrag(sourceAId);
expect(monitor.canDrop(targetAId)).to.equal(true);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(true);
backend.simulateBeginDrag([sourceAId]);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(true);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(true);
backend.simulateHover([targetAId]);
backend.simulateDrop();
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
backend.simulateEndDrag();
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(false);
expect(monitor.canDrop(targetCId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(false);
backend.simulateBeginDrag(sourceBId);
expect(monitor.canDrop(targetAId)).to.equal(false);
expect(monitor.canDrop(targetBId)).to.equal(true);
expect(monitor.canDrop(targetCId)).to.equal(true);
backend.simulateBeginDrag([sourceBId]);
_expect2['default'](monitor.canDrop(targetAId)).to.equal(false);
_expect2['default'](monitor.canDrop(targetBId)).to.equal(true);
_expect2['default'](monitor.canDrop(targetCId)).to.equal(true);
});
it("returns false from isDragging(sourceId) if source is not published", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('returns false from isDragging(sourceId) if source is not published', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
backend.simulateBeginDrag(sourceId, false);
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(false);
backend.simulateBeginDrag([sourceId], false);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
backend.simulatePublishDragSource();
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(true);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(true);
backend.simulateEndDrag();
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
});
it("ignores publishDragSource() outside dragging operation", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
it('ignores publishDragSource() outside dragging operation', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
backend.simulatePublishDragSource();
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
backend.simulateBeginDrag(sourceId, false);
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(false);
backend.simulateBeginDrag([sourceId], false);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
backend.simulatePublishDragSource();
expect(monitor.isDragging()).to.equal(true);
expect(monitor.isDragging(sourceId)).to.equal(true);
_expect2['default'](monitor.isDragging()).to.equal(true);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(true);
backend.simulateEndDrag();
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
backend.simulatePublishDragSource();
expect(monitor.isDragging()).to.equal(false);
expect(monitor.isDragging(sourceId)).to.equal(false);
_expect2['default'](monitor.isDragging()).to.equal(false);
_expect2['default'](monitor.isDragging(sourceId)).to.equal(false);
});
});
describe("target handle tracking", function () {
it("treats removing a hovered drop target as unhovering it", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
describe('target handle tracking', function () {
it('treats removing a hovered drop target as unhovering it', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover([targetId]);
expect(monitor.getTargetIds().length).to.be(1);
expect(monitor.isOver(targetId)).to.equal(true);
expect(monitor.isOver(targetId, true)).to.equal(true);
_expect2['default'](monitor.getTargetIds().length).to.be(1);
_expect2['default'](monitor.isOver(targetId)).to.equal(true);
_expect2['default'](monitor.isOver(targetId, true)).to.equal(true);
registry.removeTarget(targetId);
expect(monitor.getTargetIds().length).to.be(0);
expect(monitor.isOver(targetId)).to.equal(false);
expect(monitor.isOver(targetId, true)).to.equal(false);
_expect2['default'](monitor.getTargetIds().length).to.be(0);
_expect2['default'](monitor.isOver(targetId)).to.equal(false);
_expect2['default'](monitor.isOver(targetId, true)).to.equal(false);
});
it("keeps track of target handles", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NormalTarget();
var targetCId = registry.addTarget(Types.FOO, targetC);
it('keeps track of target handles', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetCId = registry.addTarget(_Types2['default'].FOO, targetC);
var handles = monitor.getTargetIds();
expect(handles.length).to.be(0);
_expect2['default'](handles.length).to.be(0);
backend.simulateHover([targetAId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(1);
expect(handles[0]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](handles[0]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(1);
expect(handles[0]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(true);
expect(monitor.isOver(targetAId, true)).to.equal(true);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](handles[0]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(true);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateHover([]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(0);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(0);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateHover([targetAId, targetBId, targetCId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(3);
expect(handles[0]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(true);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(handles[1]).to.equal(targetBId);
expect(monitor.isOver(targetBId)).to.equal(true);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(handles[2]).to.equal(targetCId);
expect(monitor.isOver(targetCId)).to.equal(true);
expect(monitor.isOver(targetCId, true)).to.equal(true);
_expect2['default'](handles.length).to.be(3);
_expect2['default'](handles[0]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(true);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](handles[1]).to.equal(targetBId);
_expect2['default'](monitor.isOver(targetBId)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](handles[2]).to.equal(targetCId);
_expect2['default'](monitor.isOver(targetCId)).to.equal(true);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(true);
backend.simulateHover([targetCId, targetBId, targetAId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(3);
expect(handles[0]).to.equal(targetCId);
expect(monitor.isOver(targetCId)).to.equal(true);
expect(monitor.isOver(targetCId, true)).to.equal(false);
expect(handles[1]).to.equal(targetBId);
expect(monitor.isOver(targetBId)).to.equal(true);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(handles[2]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(true);
expect(monitor.isOver(targetAId, true)).to.equal(true);
_expect2['default'](handles.length).to.be(3);
_expect2['default'](handles[0]).to.equal(targetCId);
_expect2['default'](monitor.isOver(targetCId)).to.equal(true);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles[1]).to.equal(targetBId);
_expect2['default'](monitor.isOver(targetBId)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](handles[2]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(true);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(true);

@@ -485,92 +478,92 @@ backend.simulateHover([targetBId]);

handles = monitor.getTargetIds();
expect(handles[0]).to.equal(targetBId);
expect(handles.length).to.be(1);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(true);
expect(monitor.isOver(targetBId, true)).to.equal(true);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles[0]).to.equal(targetBId);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(true);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateEndDrag();
expect(handles[0]).to.equal(targetBId);
expect(handles.length).to.be(1);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles[0]).to.equal(targetBId);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
});
it("counts non-droppable targets, but skips targets of another type", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NonDroppableTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
var targetC = new NormalTarget();
var targetCId = registry.addTarget(Types.BAR, targetC);
it('counts non-droppable targets, but skips targets of another type', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NonDroppableTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
var targetC = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetCId = registry.addTarget(_Types2['default'].BAR, targetC);
var handles = monitor.getTargetIds();
expect(handles.length).to.be(0);
_expect2['default'](handles.length).to.be(0);
backend.simulateHover([targetAId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(1);
expect(handles[0]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](handles[0]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(1);
expect(handles[0]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(true);
expect(monitor.isOver(targetAId, true)).to.equal(true);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](handles[0]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(true);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateHover([]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(0);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(0);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateHover([targetAId, targetBId, targetCId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(3);
expect(handles[0]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(true);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(handles[1]).to.equal(targetBId);
expect(monitor.isOver(targetBId)).to.equal(true);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(handles[2]).to.equal(targetCId);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles.length).to.be(3);
_expect2['default'](handles[0]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(true);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](handles[1]).to.equal(targetBId);
_expect2['default'](monitor.isOver(targetBId)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](handles[2]).to.equal(targetCId);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateHover([targetCId, targetBId, targetAId]);
handles = monitor.getTargetIds();
expect(handles.length).to.be(3);
expect(handles[0]).to.equal(targetCId);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
expect(handles[1]).to.equal(targetBId);
expect(monitor.isOver(targetBId)).to.equal(true);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(handles[2]).to.equal(targetAId);
expect(monitor.isOver(targetAId)).to.equal(true);
expect(monitor.isOver(targetAId, true)).to.equal(true);
_expect2['default'](handles.length).to.be(3);
_expect2['default'](handles[0]).to.equal(targetCId);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles[1]).to.equal(targetBId);
_expect2['default'](monitor.isOver(targetBId)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](handles[2]).to.equal(targetAId);
_expect2['default'](monitor.isOver(targetAId)).to.equal(true);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(true);

@@ -580,116 +573,116 @@ backend.simulateHover([targetBId]);

handles = monitor.getTargetIds();
expect(handles[0]).to.equal(targetBId);
expect(handles.length).to.be(1);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(true);
expect(monitor.isOver(targetBId, true)).to.equal(true);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles[0]).to.equal(targetBId);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(true);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(true);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
backend.simulateEndDrag();
expect(handles[0]).to.equal(targetBId);
expect(handles.length).to.be(1);
expect(monitor.isOver(targetAId)).to.equal(false);
expect(monitor.isOver(targetAId, true)).to.equal(false);
expect(monitor.isOver(targetBId)).to.equal(false);
expect(monitor.isOver(targetBId, true)).to.equal(false);
expect(monitor.isOver(targetCId)).to.equal(false);
expect(monitor.isOver(targetCId, true)).to.equal(false);
_expect2['default'](handles[0]).to.equal(targetBId);
_expect2['default'](handles.length).to.be(1);
_expect2['default'](monitor.isOver(targetAId)).to.equal(false);
_expect2['default'](monitor.isOver(targetAId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId)).to.equal(false);
_expect2['default'](monitor.isOver(targetBId, true)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId)).to.equal(false);
_expect2['default'](monitor.isOver(targetCId, true)).to.equal(false);
});
it("correctly handles isOver() for multi-type targets", function () {
var sourceA = new NormalSource();
var sourceAId = registry.addSource(Types.FOO, sourceA);
var sourceB = new NormalSource();
var sourceBId = registry.addSource(Types.BAR, sourceB);
var sourceC = new NormalSource();
var sourceCId = registry.addSource(Types.BAZ, sourceC);
var target = new NormalTarget();
var targetId = registry.addTarget([Types.FOO, Types.BAR], target);
it('correctly handles isOver() for multi-type targets', function () {
var sourceA = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceAId = registry.addSource(_Types2['default'].FOO, sourceA);
var sourceB = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceBId = registry.addSource(_Types2['default'].BAR, sourceB);
var sourceC = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceCId = registry.addSource(_Types2['default'].BAZ, sourceC);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget([_Types2['default'].FOO, _Types2['default'].BAR], target);
backend.simulateBeginDrag(sourceAId);
backend.simulateBeginDrag([sourceAId]);
backend.simulateHover([targetId]);
expect(monitor.isOver(targetId)).to.equal(true);
expect(monitor.isOver(targetId, true)).to.equal(true);
_expect2['default'](monitor.isOver(targetId)).to.equal(true);
_expect2['default'](monitor.isOver(targetId, true)).to.equal(true);
backend.simulateEndDrag();
backend.simulateBeginDrag(sourceBId);
expect(monitor.isOver(targetId)).to.equal(true);
expect(monitor.isOver(targetId, true)).to.equal(true);
backend.simulateBeginDrag([sourceBId]);
_expect2['default'](monitor.isOver(targetId)).to.equal(true);
_expect2['default'](monitor.isOver(targetId, true)).to.equal(true);
backend.simulateEndDrag();
backend.simulateBeginDrag(sourceCId);
expect(monitor.isOver(targetId)).to.equal(false);
expect(monitor.isOver(targetId, true)).to.equal(false);
backend.simulateBeginDrag([sourceCId]);
_expect2['default'](monitor.isOver(targetId)).to.equal(false);
_expect2['default'](monitor.isOver(targetId, true)).to.equal(false);
});
it("does not reset target handles on drop() and endDrag()", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var targetA = new NormalTarget();
var targetAId = registry.addTarget(Types.FOO, targetA);
var targetB = new NormalTarget();
var targetBId = registry.addTarget(Types.FOO, targetB);
it('does not reset target handles on drop() and endDrag()', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var targetA = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetAId = registry.addTarget(_Types2['default'].FOO, targetA);
var targetB = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetBId = registry.addTarget(_Types2['default'].FOO, targetB);
expect(monitor.getTargetIds().length).to.be(0);
_expect2['default'](monitor.getTargetIds().length).to.be(0);
backend.simulateHover([targetAId, targetBId]);
expect(monitor.getTargetIds().length).to.be(2);
_expect2['default'](monitor.getTargetIds().length).to.be(2);
backend.simulateBeginDrag(sourceId);
expect(monitor.getTargetIds().length).to.be(2);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.getTargetIds().length).to.be(2);
backend.simulateDrop();
expect(monitor.getTargetIds().length).to.be(2);
_expect2['default'](monitor.getTargetIds().length).to.be(2);
backend.simulateEndDrag();
expect(monitor.getTargetIds().length).to.be(2);
_expect2['default'](monitor.getTargetIds().length).to.be(2);
backend.simulateHover([targetAId]);
expect(monitor.getTargetIds().length).to.be(1);
_expect2['default'](monitor.getTargetIds().length).to.be(1);
backend.simulateBeginDrag(sourceId);
expect(monitor.getTargetIds().length).to.be(1);
backend.simulateBeginDrag([sourceId]);
_expect2['default'](monitor.getTargetIds().length).to.be(1);
});
it("does not let array mutation corrupt internal state", function () {
var source = new NormalSource();
var sourceId = registry.addSource(Types.FOO, source);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
it('does not let array mutation corrupt internal state', function () {
var source = new _NormalSource$NonDraggableSource$NumberSource.NormalSource();
var sourceId = registry.addSource(_Types2['default'].FOO, source);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
var handles = [targetId];
backend.simulateBeginDrag(sourceId);
backend.simulateBeginDrag([sourceId]);
backend.simulateHover(handles);
expect(monitor.getTargetIds().length).to.be(1);
_expect2['default'](monitor.getTargetIds().length).to.be(1);
handles.push(targetId);
expect(monitor.getTargetIds().length).to.be(1);
_expect2['default'](monitor.getTargetIds().length).to.be(1);
});
});
describe("mirror drag sources", function () {
it("uses custom isDragging functions", function () {
var sourceA = new NumberSource(1, true);
var sourceAId = registry.addSource(Types.FOO, sourceA);
var sourceB = new NumberSource(2, true);
var sourceBId = registry.addSource(Types.FOO, sourceB);
var sourceC = new NumberSource(3, true);
var sourceCId = registry.addSource(Types.BAR, sourceC);
var sourceD = new NumberSource(4, false);
var sourceDId = registry.addSource(Types.FOO, sourceD);
var target = new NormalTarget();
var targetId = registry.addTarget(Types.FOO, target);
describe('mirror drag sources', function () {
it('uses custom isDragging functions', function () {
var sourceA = new _NormalSource$NonDraggableSource$NumberSource.NumberSource(1, true);
var sourceAId = registry.addSource(_Types2['default'].FOO, sourceA);
var sourceB = new _NormalSource$NonDraggableSource$NumberSource.NumberSource(2, true);
var sourceBId = registry.addSource(_Types2['default'].FOO, sourceB);
var sourceC = new _NormalSource$NonDraggableSource$NumberSource.NumberSource(3, true);
var sourceCId = registry.addSource(_Types2['default'].BAR, sourceC);
var sourceD = new _NormalSource$NonDraggableSource$NumberSource.NumberSource(4, false);
var sourceDId = registry.addSource(_Types2['default'].FOO, sourceD);
var target = new _NormalTarget$NonDroppableTarget$TargetWithNoDropResult.NormalTarget();
var targetId = registry.addTarget(_Types2['default'].FOO, target);
expect(monitor.isDragging(sourceAId)).to.equal(false);
expect(monitor.isDragging(sourceBId)).to.equal(false);
expect(monitor.isDragging(sourceCId)).to.equal(false);
expect(monitor.isDragging(sourceDId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceCId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceDId)).to.equal(false);
backend.simulateBeginDrag(sourceAId);
expect(monitor.isDragging(sourceAId)).to.equal(true);
expect(monitor.isDragging(sourceBId)).to.equal(false);
expect(monitor.isDragging(sourceCId)).to.equal(false);
expect(monitor.isDragging(sourceDId)).to.equal(false);
backend.simulateBeginDrag([sourceAId]);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(true);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceCId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceDId)).to.equal(false);

@@ -700,6 +693,6 @@ sourceA.number = 3;

sourceD.number = 1;
expect(monitor.isDragging(sourceAId)).to.equal(false);
expect(monitor.isDragging(sourceBId)).to.equal(true);
expect(monitor.isDragging(sourceCId)).to.equal(false);
expect(monitor.isDragging(sourceDId)).to.equal(true);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(true);
_expect2['default'](monitor.isDragging(sourceCId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceDId)).to.equal(true);

@@ -709,26 +702,26 @@ registry.removeSource(sourceDId);

backend.simulateDrop();
expect(monitor.isDragging(sourceAId)).to.equal(false);
expect(monitor.isDragging(sourceBId)).to.equal(true);
expect(monitor.isDragging(sourceCId)).to.equal(false);
expect(monitor.isDragging(sourceDId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(true);
_expect2['default'](monitor.isDragging(sourceCId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceDId)).to.equal(false);
backend.simulateEndDrag();
expect(monitor.isDragging(sourceAId)).to.equal(false);
expect(monitor.isDragging(sourceBId)).to.equal(false);
expect(monitor.isDragging(sourceCId)).to.equal(false);
expect(monitor.isDragging(sourceDId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceCId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceDId)).to.equal(false);
backend.simulateBeginDrag(sourceBId);
expect(monitor.isDragging(sourceAId)).to.equal(false);
expect(monitor.isDragging(sourceBId)).to.equal(true);
expect(monitor.isDragging(sourceCId)).to.equal(false);
expect(monitor.isDragging(sourceDId)).to.equal(false);
backend.simulateBeginDrag([sourceBId]);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(true);
_expect2['default'](monitor.isDragging(sourceCId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceDId)).to.equal(false);
sourceA.number = 1;
expect(monitor.isDragging(sourceAId)).to.equal(true);
_expect2['default'](monitor.isDragging(sourceAId)).to.equal(true);
sourceB.number = 5;
expect(monitor.isDragging(sourceBId)).to.equal(false);
_expect2['default'](monitor.isDragging(sourceBId)).to.equal(false);
});
});
});

@@ -1,13 +0,16 @@

"use strict";
'use strict';
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var DragSource = require("..").DragSource;
exports.__esModule = true;
var NormalSource = exports.NormalSource = (function (_DragSource) {
var _DragSource5 = require('..');
var NormalSource = (function (_DragSource) {
function NormalSource(item) {
_classCallCheck(this, NormalSource);
_DragSource.call(this);
this.item = item || { baz: 42 };

@@ -29,8 +32,11 @@ this.didCallBeginDrag = false;

return NormalSource;
})(DragSource);
})(_DragSource5.DragSource);
var NonDraggableSource = exports.NonDraggableSource = (function (_DragSource2) {
exports.NormalSource = NormalSource;
var NonDraggableSource = (function (_DragSource2) {
function NonDraggableSource() {
_classCallCheck(this, NonDraggableSource);
_DragSource2.call(this);
this.didCallBeginDrag = false;

@@ -51,5 +57,7 @@ }

return NonDraggableSource;
})(DragSource);
})(_DragSource5.DragSource);
var BadItemSource = exports.BadItemSource = (function (_DragSource3) {
exports.NonDraggableSource = NonDraggableSource;
var BadItemSource = (function (_DragSource3) {
function BadItemSource() {

@@ -70,8 +78,11 @@ _classCallCheck(this, BadItemSource);

return BadItemSource;
})(DragSource);
})(_DragSource5.DragSource);
var NumberSource = exports.NumberSource = (function (_DragSource4) {
exports.BadItemSource = BadItemSource;
var NumberSource = (function (_DragSource4) {
function NumberSource(number, allowDrag) {
_classCallCheck(this, NumberSource);
_DragSource4.call(this);
this.number = number;

@@ -99,4 +110,4 @@ this.allowDrag = allowDrag;

return NumberSource;
})(DragSource);
})(_DragSource5.DragSource);
exports.__esModule = true;
exports.NumberSource = NumberSource;

@@ -1,16 +0,19 @@

"use strict";
'use strict';
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var DropTarget = require("..").DropTarget;
exports.__esModule = true;
var NormalTarget = exports.NormalTarget = (function (_DropTarget) {
var _DropTarget6 = require('..');
var NormalTarget = (function (_DropTarget) {
function NormalTarget(dropResult) {
_classCallCheck(this, NormalTarget);
_DropTarget.call(this);
this.didCallDrop = false;
this.didCallHover = false;
this.dropResult = dropResult || { foo: "bar" };
this.dropResult = dropResult || { foo: 'bar' };
}

@@ -30,8 +33,11 @@

return NormalTarget;
})(DropTarget);
})(_DropTarget6.DropTarget);
var NonDroppableTarget = exports.NonDroppableTarget = (function (_DropTarget2) {
exports.NormalTarget = NormalTarget;
var NonDroppableTarget = (function (_DropTarget2) {
function NonDroppableTarget() {
_classCallCheck(this, NonDroppableTarget);
_DropTarget2.call(this);
this.didCallDrop = false;

@@ -56,8 +62,11 @@ this.didCallHover = false;

return NonDroppableTarget;
})(DropTarget);
})(_DropTarget6.DropTarget);
var TargetWithNoDropResult = exports.TargetWithNoDropResult = (function (_DropTarget3) {
exports.NonDroppableTarget = NonDroppableTarget;
var TargetWithNoDropResult = (function (_DropTarget3) {
function TargetWithNoDropResult() {
_classCallCheck(this, TargetWithNoDropResult);
_DropTarget3.call(this);
this.didCallDrop = false;

@@ -78,5 +87,7 @@ this.didCallHover = false;

return TargetWithNoDropResult;
})(DropTarget);
})(_DropTarget6.DropTarget);
var BadResultTarget = exports.BadResultTarget = (function (_DropTarget4) {
exports.TargetWithNoDropResult = TargetWithNoDropResult;
var BadResultTarget = (function (_DropTarget4) {
function BadResultTarget() {

@@ -97,8 +108,11 @@ _classCallCheck(this, BadResultTarget);

return BadResultTarget;
})(DropTarget);
})(_DropTarget6.DropTarget);
var TransformResultTarget = exports.TransformResultTarget = (function (_DropTarget5) {
exports.BadResultTarget = BadResultTarget;
var TransformResultTarget = (function (_DropTarget5) {
function TransformResultTarget(transform) {
_classCallCheck(this, TransformResultTarget);
_DropTarget5.call(this);
this.transform = transform;

@@ -122,4 +136,4 @@ this.didCallDrop = false;

return TransformResultTarget;
})(DropTarget);
})(_DropTarget6.DropTarget);
exports.__esModule = true;
exports.TransformResultTarget = TransformResultTarget;

@@ -1,11 +0,16 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var keyMirror = _interopRequire(require("keymirror"));
exports.__esModule = true;
module.exports = keyMirror({
var _keyMirror = require('keymirror');
var _keyMirror2 = _interopRequireWildcard(_keyMirror);
exports['default'] = _keyMirror2['default']({
FOO: null,
BAR: null,
BAZ: null
});
});
module.exports = exports['default'];

@@ -1,19 +0,29 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var Actions = require("flummox").Actions;
exports.__esModule = true;
var matchesType = _interopRequire(require("../utils/matchesType"));
var _Actions2 = require('flummox');
var invariant = _interopRequire(require("invariant"));
var _matchesType = require('../utils/matchesType');
var isArray = _interopRequire(require("lodash/lang/isArray"));
var _matchesType2 = _interopRequireWildcard(_matchesType);
var isObject = _interopRequire(require("lodash/lang/isObject"));
var _invariant = require('invariant');
var _invariant2 = _interopRequireWildcard(_invariant);
var _isArray = require('lodash/lang/isArray');
var _isArray2 = _interopRequireWildcard(_isArray);
var _isObject = require('lodash/lang/isObject');
var _isObject2 = _interopRequireWildcard(_isObject);
var DragDropActions = (function (_Actions) {

@@ -29,9 +39,23 @@ function DragDropActions(manager) {

DragDropActions.prototype.beginDrag = function beginDrag(sourceId) {
var isSourcePublic = arguments[1] === undefined ? true : arguments[1];
DragDropActions.prototype.beginDrag = function beginDrag(sourceIds) {
var publishSource = arguments[1] === undefined ? true : arguments[1];
_invariant2['default'](_isArray2['default'](sourceIds), 'Expected sourceIds to be an array.');
var monitor = this.manager.getMonitor();
var registry = this.manager.getRegistry();
invariant(!monitor.isDragging(), "Cannot call beginDrag while dragging.");
if (!monitor.canDrag(sourceId)) {
_invariant2['default'](!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
for (var i = 0; i < sourceIds.length; i++) {
_invariant2['default'](registry.getSource(sourceIds[i]), 'Expected sourceIds to be registered.');
}
var sourceId = null;
for (var i = sourceIds.length - 1; i >= 0; i--) {
if (monitor.canDrag(sourceIds[i])) {
sourceId = sourceIds[i];
break;
}
}
if (sourceId === null) {
return;

@@ -42,3 +66,3 @@ }

var item = source.beginDrag(monitor, sourceId);
invariant(isObject(item), "Item must be an object.");
_invariant2['default'](_isObject2['default'](item), 'Item must be an object.');

@@ -48,3 +72,3 @@ registry.pinSource(sourceId);

var itemType = registry.getSourceType(sourceId);
return { itemType: itemType, item: item, sourceId: sourceId, isSourcePublic: isSourcePublic };
return { itemType: itemType, item: item, sourceId: sourceId, isSourcePublic: publishSource };
};

@@ -62,3 +86,3 @@

DragDropActions.prototype.hover = function hover(targetIds) {
invariant(isArray(targetIds), "Target handles must be an array.");
_invariant2['default'](_isArray2['default'](targetIds), 'Expected targetIds to be an array.');
targetIds = targetIds.slice(0);

@@ -79,9 +103,9 @@

var targetId = targetIds[i];
invariant(targetIds.lastIndexOf(targetId) === i, "Target handles should be unique in the passed array.");
_invariant2['default'](targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
var target = registry.getTarget(targetId);
invariant(target, "All hovered target handles must be registered.");
_invariant2['default'](target, 'Expected targetIds to be registered.');
var targetType = registry.getTargetType(targetId);
if (matchesType(targetType, draggedItemType)) {
if (_matchesType2['default'](targetType, draggedItemType)) {
target.hover(monitor, targetId);

@@ -107,3 +131,3 @@ }

var registry = this.manager.getRegistry();
invariant(monitor.isDragging(), "Cannot call drop while not dragging.");
_invariant2['default'](monitor.isDragging(), 'Cannot call drop while not dragging.');

@@ -121,4 +145,4 @@ var _getActionIds = this.getActionIds();

var dropResult = target.drop(monitor, targetId);
invariant(typeof dropResult === "undefined" || isObject(dropResult), "Drop result must either be an object or undefined.");
if (typeof dropResult === "undefined") {
_invariant2['default'](typeof dropResult === 'undefined' || _isObject2['default'](dropResult), 'Drop result must either be an object or undefined.');
if (typeof dropResult === 'undefined') {
dropResult = index === 0 ? true : monitor.getDropResult();

@@ -134,3 +158,3 @@ }

var registry = this.manager.getRegistry();
invariant(monitor.isDragging(), "Cannot call endDrag while not dragging.");
_invariant2['default'](monitor.isDragging(), 'Cannot call endDrag while not dragging.');

@@ -147,4 +171,5 @@ var sourceId = monitor.getSourceId();

return DragDropActions;
})(Actions);
})(_Actions2.Actions);
module.exports = DragDropActions;
exports['default'] = DragDropActions;
module.exports = exports['default'];

@@ -1,9 +0,11 @@

"use strict";
'use strict';
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var Actions = require("flummox").Actions;
exports.__esModule = true;
var _Actions2 = require('flummox');
var RegistryActions = (function (_Actions) {

@@ -37,4 +39,5 @@ function RegistryActions() {

return RegistryActions;
})(Actions);
})(_Actions2.Actions);
module.exports = RegistryActions;
exports['default'] = RegistryActions;
module.exports = exports['default'];

@@ -5,2 +5,4 @@ "use strict";

exports.__esModule = true;
var TestBackend = (function () {

@@ -21,4 +23,4 @@ function TestBackend(actions) {

TestBackend.prototype.simulateBeginDrag = function simulateBeginDrag(sourceId, isSourcePublic) {
this.actions.beginDrag(sourceId, isSourcePublic);
TestBackend.prototype.simulateBeginDrag = function simulateBeginDrag(sourceIds, publishSource) {
this.actions.beginDrag(sourceIds, publishSource);
};

@@ -45,2 +47,3 @@

module.exports = TestBackend;
exports["default"] = TestBackend;
module.exports = exports["default"];

@@ -1,13 +0,21 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var Flux = _interopRequire(require("./Flux"));
exports.__esModule = true;
var DragDropMonitor = _interopRequire(require("./DragDropMonitor"));
var _Flux = require('./Flux');
var HandlerRegistry = _interopRequire(require("./utils/HandlerRegistry"));
var _Flux2 = _interopRequireWildcard(_Flux);
var _DragDropMonitor = require('./DragDropMonitor');
var _DragDropMonitor2 = _interopRequireWildcard(_DragDropMonitor);
var _HandlerRegistry = require('./utils/HandlerRegistry');
var _HandlerRegistry2 = _interopRequireWildcard(_HandlerRegistry);
var DragDropManager = (function () {

@@ -17,10 +25,10 @@ function DragDropManager(Backend) {

var flux = new Flux(this);
var flux = new _Flux2['default'](this);
this.flux = flux;
this.registry = new HandlerRegistry(flux.registryActions);
this.monitor = new DragDropMonitor(flux, this.registry);
this.registry = new _HandlerRegistry2['default'](flux.registryActions);
this.monitor = new _DragDropMonitor2['default'](flux, this.registry);
this.backend = new Backend(flux.dragDropActions, this.monitor, this.registry);
flux.refCountStore.addListener("change", this.handleRefCountChange, this);
flux.refCountStore.addListener('change', this.handleRefCountChange, this);
}

@@ -54,2 +62,3 @@

module.exports = DragDropManager;
exports['default'] = DragDropManager;
module.exports = exports['default'];

@@ -1,11 +0,17 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var invariant = _interopRequire(require("invariant"));
exports.__esModule = true;
var matchesType = _interopRequire(require("./utils/matchesType"));
var _invariant = require('invariant');
var _invariant2 = _interopRequireWildcard(_invariant);
var _matchesType = require('./utils/matchesType');
var _matchesType2 = _interopRequireWildcard(_matchesType);
var DragDropMonitor = (function () {

@@ -20,7 +26,7 @@ function DragDropMonitor(flux, registry) {

DragDropMonitor.prototype.addChangeListener = function addChangeListener(listener) {
this.dragOperationStore.addListener("change", listener);
this.dragOperationStore.addListener('change', listener);
};
DragDropMonitor.prototype.removeChangeListener = function removeChangeListener(listener) {
this.dragOperationStore.removeListener("change", listener);
this.dragOperationStore.removeListener('change', listener);
};

@@ -30,3 +36,3 @@

var source = this.registry.getSource(sourceId);
invariant(source, "Expected to find a valid source.");
_invariant2['default'](source, 'Expected to find a valid source.');

@@ -42,3 +48,3 @@ if (this.isDragging()) {

var target = this.registry.getTarget(targetId);
invariant(target, "Expected to find a valid target.");
_invariant2['default'](target, 'Expected to find a valid target.');

@@ -51,8 +57,18 @@ if (!this.isDragging() || this.didDrop()) {

var draggedItemType = this.getItemType();
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
return _matchesType2['default'](targetType, draggedItemType) && target.canDrop(this, targetId);
};
DragDropMonitor.prototype.isDragging = function isDragging(sourceId) {
DragDropMonitor.prototype.isDragging = (function (_isDragging) {
function isDragging(_x) {
return _isDragging.apply(this, arguments);
}
isDragging.toString = function () {
return _isDragging.toString();
};
return isDragging;
})(function (sourceId) {
var isDragging = this.dragOperationStore.isDragging();
if (!isDragging || typeof sourceId === "undefined") {
if (!isDragging || typeof sourceId === 'undefined') {
return isDragging;

@@ -77,3 +93,3 @@ }

return source.isDragging(this, sourceId);
};
});

@@ -89,3 +105,3 @@ DragDropMonitor.prototype.isOver = function isOver(targetId) {

var draggedItemType = this.getItemType();
if (!matchesType(targetType, draggedItemType)) {
if (!_matchesType2['default'](targetType, draggedItemType)) {
return false;

@@ -138,2 +154,3 @@ }

module.exports = DragDropMonitor;
exports['default'] = DragDropMonitor;
module.exports = exports['default'];

@@ -5,2 +5,4 @@ "use strict";

exports.__esModule = true;
var DragSource = (function () {

@@ -24,2 +26,3 @@ function DragSource() {

module.exports = DragSource;
exports["default"] = DragSource;
module.exports = exports["default"];

@@ -5,2 +5,4 @@ "use strict";

exports.__esModule = true;
var DropTarget = (function () {

@@ -22,2 +24,3 @@ function DropTarget() {

module.exports = DropTarget;
exports["default"] = DropTarget;
module.exports = exports["default"];

@@ -1,19 +0,29 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var Flummox = require("flummox").Flummox;
exports.__esModule = true;
var DragDropActions = _interopRequire(require("./actions/DragDropActions"));
var _Flummox2 = require('flummox');
var RegistryActions = _interopRequire(require("./actions/RegistryActions"));
var _DragDropActions = require('./actions/DragDropActions');
var DragOperationStore = _interopRequire(require("./stores/DragOperationStore"));
var _DragDropActions2 = _interopRequireWildcard(_DragDropActions);
var RefCountStore = _interopRequire(require("./stores/RefCountStore"));
var _RegistryActions = require('./actions/RegistryActions');
var _RegistryActions2 = _interopRequireWildcard(_RegistryActions);
var _DragOperationStore = require('./stores/DragOperationStore');
var _DragOperationStore2 = _interopRequireWildcard(_DragOperationStore);
var _RefCountStore = require('./stores/RefCountStore');
var _RefCountStore2 = _interopRequireWildcard(_RefCountStore);
var Flux = (function (_Flummox) {

@@ -25,11 +35,11 @@ function Flux(manager) {

this.dragDropActions = this.createActions("dragDropActions", DragDropActions, manager);
this.dragDropActionIds = this.getActionIds("dragDropActions");
this.dragDropActions = this.createActions('dragDropActions', _DragDropActions2['default'], manager);
this.dragDropActionIds = this.getActionIds('dragDropActions');
this.registryActions = this.createActions("registryActions", RegistryActions);
this.registryActionIds = this.getActionIds("registryActions");
this.registryActions = this.createActions('registryActions', _RegistryActions2['default']);
this.registryActionIds = this.getActionIds('registryActions');
this.dragOperationStore = this.createStore("dragOperationStore", DragOperationStore, this);
this.dragOperationStore = this.createStore('dragOperationStore', _DragOperationStore2['default'], this);
this.refCountStore = this.createStore("refCountStore", RefCountStore, this);
this.refCountStore = this.createStore('refCountStore', _RefCountStore2['default'], this);
}

@@ -40,4 +50,5 @@

return Flux;
})(Flummox);
})(_Flummox2.Flummox);
module.exports = Flux;
exports['default'] = Flux;
module.exports = exports['default'];

@@ -1,9 +0,21 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
exports.DragDropManager = _interopRequire(require("./DragDropManager"));
exports.DragSource = _interopRequire(require("./DragSource"));
exports.DropTarget = _interopRequire(require("./DropTarget"));
exports.TestBackend = _interopRequire(require("./backends/TestBackend"));
exports.__esModule = true;
exports.__esModule = true;
var _default = require('./DragDropManager');
exports.DragDropManager = _interopRequire(_default);
var _default2 = require('./DragSource');
exports.DragSource = _interopRequire(_default2);
var _default3 = require('./DropTarget');
exports.DropTarget = _interopRequire(_default3);
var _default4 = require('./backends/TestBackend');
exports.TestBackend = _interopRequire(_default4);

@@ -1,13 +0,17 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var Store = require("flummox").Store;
exports.__esModule = true;
var without = _interopRequire(require("lodash/array/without"));
var _Store2 = require('flummox');
var _without = require('lodash/array/without');
var _without2 = _interopRequireWildcard(_without);
var DragOperationStore = (function (_Store) {

@@ -62,4 +66,4 @@ function DragOperationStore(flux) {

DragOperationStore.prototype.handleHover = function handleHover(_ref) {
var targetIds = _ref.targetIds;
DragOperationStore.prototype.handleHover = function handleHover(_ref2) {
var targetIds = _ref2.targetIds;

@@ -69,4 +73,4 @@ this.setState({ targetIds: targetIds });

DragOperationStore.prototype.handleRemoveTarget = function handleRemoveTarget(_ref) {
var targetId = _ref.targetId;
DragOperationStore.prototype.handleRemoveTarget = function handleRemoveTarget(_ref3) {
var targetId = _ref3.targetId;
var targetIds = this.state.targetIds;

@@ -76,3 +80,3 @@

this.setState({
targetIds: without(targetIds, targetId)
targetIds: _without2['default'](targetIds, targetId)
});

@@ -82,4 +86,4 @@ }

DragOperationStore.prototype.handleDrop = function handleDrop(_ref) {
var dropResult = _ref.dropResult;
DragOperationStore.prototype.handleDrop = function handleDrop(_ref4) {
var dropResult = _ref4.dropResult;

@@ -136,4 +140,5 @@ this.setState({

return DragOperationStore;
})(Store);
})(_Store2.Store);
module.exports = DragOperationStore;
exports['default'] = DragOperationStore;
module.exports = exports['default'];

@@ -1,9 +0,11 @@

"use strict";
'use strict';
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var Store = require("flummox").Store;
exports.__esModule = true;
var _Store2 = require('flummox');
var RefCountStore = (function (_Store) {

@@ -46,4 +48,5 @@ function RefCountStore(flux) {

return RefCountStore;
})(Store);
})(_Store2.Store);
module.exports = RefCountStore;
exports['default'] = RefCountStore;
module.exports = exports['default'];
"use strict";
module.exports = getNextUniqueId;
exports.__esModule = true;
exports["default"] = getNextUniqueId;
var nextUniqueId = 0;

@@ -8,2 +9,4 @@

return nextUniqueId++;
}
}
module.exports = exports["default"];

@@ -1,16 +0,26 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var invariant = _interopRequire(require("invariant"));
exports.__esModule = true;
var keyMirror = _interopRequire(require("keymirror"));
var _invariant = require('invariant');
var isArray = _interopRequire(require("lodash/lang/isArray"));
var _invariant2 = _interopRequireWildcard(_invariant);
var getNextUniqueId = _interopRequire(require("./getNextUniqueId"));
var _keyMirror = require('keymirror');
var HandlerRoles = keyMirror({
var _keyMirror2 = _interopRequireWildcard(_keyMirror);
var _isArray = require('lodash/lang/isArray');
var _isArray2 = _interopRequireWildcard(_isArray);
var _getNextUniqueId = require('./getNextUniqueId');
var _getNextUniqueId2 = _interopRequireWildcard(_getNextUniqueId);
var HandlerRoles = _keyMirror2['default']({
SOURCE: null,

@@ -21,15 +31,15 @@ TARGET: null

function validateSourceContract(source) {
invariant(typeof source.canDrag === "function", "Expected canDrag to be a function.");
invariant(typeof source.beginDrag === "function", "Expected beginDrag to be a function.");
invariant(typeof source.endDrag === "function", "Expected endDrag to be a function.");
_invariant2['default'](typeof source.canDrag === 'function', 'Expected canDrag to be a function.');
_invariant2['default'](typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.');
_invariant2['default'](typeof source.endDrag === 'function', 'Expected endDrag to be a function.');
}
function validateTargetContract(target) {
invariant(typeof target.canDrop === "function", "Expected canDrop to be a function.");
invariant(typeof target.hover === "function", "Expected hover to be a function.");
invariant(typeof target.drop === "function", "Expected beginDrag to be a function.");
_invariant2['default'](typeof target.canDrop === 'function', 'Expected canDrop to be a function.');
_invariant2['default'](typeof target.hover === 'function', 'Expected hover to be a function.');
_invariant2['default'](typeof target.drop === 'function', 'Expected beginDrag to be a function.');
}
function validateType(type, allowArray) {
if (allowArray && isArray(type)) {
if (allowArray && _isArray2['default'](type)) {
type.forEach(function (t) {

@@ -41,14 +51,14 @@ return validateType(t, false);

invariant(typeof type === "string", allowArray ? "Type can only be a string or an array of them." : "Type can only be a string.");
_invariant2['default'](typeof type === 'string', allowArray ? 'Type can only be a string or an array of them.' : 'Type can only be a string.');
}
function getNextHandlerId(role) {
var id = getNextUniqueId().toString();
var id = _getNextUniqueId2['default']().toString();
switch (role) {
case HandlerRoles.SOURCE:
return "S" + id;
return 'S' + id;
case HandlerRoles.TARGET:
return "T" + id;
return 'T' + id;
default:
invariant(false, "Unknown role: " + role);
_invariant2['default'](false, 'Unknown role: ' + role);
}

@@ -59,8 +69,8 @@ }

switch (handlerId[0]) {
case "S":
case 'S':
return HandlerRoles.SOURCE;
case "T":
case 'T':
return HandlerRoles.TARGET;
default:
invariant(false, "Cannot parse handler ID: " + handlerId);
_invariant2['default'](false, 'Cannot parse handler ID: ' + handlerId);
}

@@ -101,4 +111,4 @@ }

HandlerRegistry.prototype.addHandler = function addHandler(role, type, handler) {
if (process.env.NODE_ENV !== "production") {
invariant(!this.containsHandler(handler), "Cannot add the same handler instance twice.");
if (process.env.NODE_ENV !== 'production') {
_invariant2['default'](!this.containsHandler(handler), 'Cannot add the same handler instance twice.');
}

@@ -122,3 +132,3 @@

HandlerRegistry.prototype.getSource = function getSource(sourceId, includePinned) {
invariant(this.isSourceId(sourceId), "Expected a valid source ID.");
_invariant2['default'](this.isSourceId(sourceId), 'Expected a valid source ID.');

@@ -132,3 +142,3 @@ var isPinned = includePinned && sourceId === this.pinnedSourceId;

HandlerRegistry.prototype.getTarget = function getTarget(targetId) {
invariant(this.isTargetId(targetId), "Expected a valid target ID.");
_invariant2['default'](this.isTargetId(targetId), 'Expected a valid target ID.');
return this.handlers[targetId];

@@ -138,3 +148,3 @@ };

HandlerRegistry.prototype.getSourceType = function getSourceType(sourceId) {
invariant(this.isSourceId(sourceId), "Expected a valid source ID.");
_invariant2['default'](this.isSourceId(sourceId), 'Expected a valid source ID.');
return this.types[sourceId];

@@ -144,3 +154,3 @@ };

HandlerRegistry.prototype.getTargetType = function getTargetType(targetId) {
invariant(this.isTargetId(targetId), "Expected a valid target ID.");
_invariant2['default'](this.isTargetId(targetId), 'Expected a valid target ID.');
return this.types[targetId];

@@ -160,3 +170,3 @@ };

HandlerRegistry.prototype.removeSource = function removeSource(sourceId) {
invariant(this.getSource(sourceId), "Expected an existing source.");
_invariant2['default'](this.getSource(sourceId), 'Expected an existing source.');

@@ -170,3 +180,3 @@ delete this.handlers[sourceId];

HandlerRegistry.prototype.removeTarget = function removeTarget(targetId) {
invariant(this.getTarget(targetId), "Expected an existing target.");
_invariant2['default'](this.getTarget(targetId), 'Expected an existing target.');

@@ -181,3 +191,3 @@ delete this.handlers[targetId];

var source = this.getSource(sourceId);
invariant(source, "Expected an existing source.");
_invariant2['default'](source, 'Expected an existing source.');

@@ -189,3 +199,3 @@ this.pinnedSourceId = sourceId;

HandlerRegistry.prototype.unpinSource = function unpinSource() {
invariant(this.pinnedSource, "No source is pinned at the time.");
_invariant2['default'](this.pinnedSource, 'No source is pinned at the time.');

@@ -199,2 +209,3 @@ this.pinnedSourceId = null;

module.exports = HandlerRegistry;
exports['default'] = HandlerRegistry;
module.exports = exports['default'];

@@ -1,11 +0,14 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
module.exports = matchesType;
exports.__esModule = true;
exports['default'] = matchesType;
var isArray = _interopRequire(require("lodash/lang/isArray"));
var _isArray = require('lodash/lang/isArray');
var _isArray2 = _interopRequireWildcard(_isArray);
function matchesType(targetType, draggedItemType) {
if (isArray(targetType)) {
if (_isArray2['default'](targetType)) {
return targetType.some(function (t) {

@@ -17,2 +20,4 @@ return t === draggedItemType;

}
}
}
module.exports = exports['default'];
{
"name": "dnd-core",
"version": "0.7.0",
"version": "0.8.0",
"description": "Drag and drop sans the GUI",

@@ -23,3 +23,3 @@ "main": "dist-modules/index.js",

"devDependencies": {
"babel": "^4.6.6",
"babel": "^5.0.10",
"expect.js": "^0.3.1",

@@ -26,0 +26,0 @@ "istanbul": "~0.3.7",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc