Comparing version 15.0.1 to 15.0.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createBeginDrag = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
const setClientOffset_1 = require("./local/setClientOffset"); | ||
const js_utils_1 = require("../../utils/js_utils"); | ||
const types_1 = require("./types"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createBeginDrag = createBeginDrag; | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _setClientOffset = require("./local/setClientOffset"); | ||
var _jsUtils = require("../../utils/js_utils"); | ||
var _types = require("./types"); | ||
const ResetCoordinatesAction = { | ||
type: types_1.INIT_COORDS, | ||
type: _types.INIT_COORDS, | ||
payload: { | ||
clientOffset: null, | ||
sourceClientOffset: null, | ||
}, | ||
sourceClientOffset: null | ||
} | ||
}; | ||
function createBeginDrag(manager) { | ||
return function beginDrag(sourceIds = [], options = { | ||
publishSource: true, | ||
publishSource: true | ||
}) { | ||
const { publishSource = true, clientOffset, getSourceClientOffset, } = options; | ||
const { publishSource =true , clientOffset , getSourceClientOffset , } = options; | ||
const monitor = manager.getMonitor(); | ||
const registry = manager.getRegistry(); | ||
// Initialize the coordinates using the client offset | ||
manager.dispatch((0, setClientOffset_1.setClientOffset)(clientOffset)); | ||
manager.dispatch((0, _setClientOffset).setClientOffset(clientOffset)); | ||
verifyInvariants(sourceIds, monitor, registry); | ||
@@ -41,3 +43,3 @@ // Get the draggable source | ||
// Initialize the full coordinates | ||
manager.dispatch((0, setClientOffset_1.setClientOffset)(clientOffset, sourceClientOffset)); | ||
manager.dispatch((0, _setClientOffset).setClientOffset(clientOffset, sourceClientOffset)); | ||
const source = registry.getSource(sourceId); | ||
@@ -53,3 +55,3 @@ const item = source.beginDrag(monitor, sourceId); | ||
return { | ||
type: types_1.BEGIN_DRAG, | ||
type: _types.BEGIN_DRAG, | ||
payload: { | ||
@@ -61,23 +63,22 @@ itemType, | ||
sourceClientOffset: sourceClientOffset || null, | ||
isSourcePublic: !!publishSource, | ||
}, | ||
isSourcePublic: !!publishSource | ||
} | ||
}; | ||
}; | ||
} | ||
exports.createBeginDrag = createBeginDrag; | ||
function verifyInvariants(sourceIds, monitor, registry) { | ||
(0, invariant_1.invariant)(!monitor.isDragging(), 'Cannot call beginDrag while dragging.'); | ||
sourceIds.forEach(function (sourceId) { | ||
(0, invariant_1.invariant)(registry.getSource(sourceId), 'Expected sourceIds to be registered.'); | ||
(0, _invariant).invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.'); | ||
sourceIds.forEach(function(sourceId) { | ||
(0, _invariant).invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.'); | ||
}); | ||
} | ||
function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) { | ||
(0, invariant_1.invariant)(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.'); | ||
(0, _invariant).invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.'); | ||
} | ||
function verifyItemIsObject(item) { | ||
(0, invariant_1.invariant)((0, js_utils_1.isObject)(item), 'Item must be an object.'); | ||
(0, _invariant).invariant((0, _jsUtils).isObject(item), 'Item must be an object.'); | ||
} | ||
function getDraggableSource(sourceIds, monitor) { | ||
let sourceId = null; | ||
for (let i = sourceIds.length - 1; i >= 0; i--) { | ||
for(let i = sourceIds.length - 1; i >= 0; i--){ | ||
if (monitor.canDragSource(sourceIds[i])) { | ||
@@ -90,1 +91,3 @@ sourceId = sourceIds[i]; | ||
} | ||
//# sourceMappingURL=beginDrag.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDrop = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
const types_1 = require("./types"); | ||
const js_utils_1 = require("../../utils/js_utils"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createDrop = createDrop; | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _types = require("./types"); | ||
var _jsUtils = require("../../utils/js_utils"); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function createDrop(manager) { | ||
@@ -14,12 +44,9 @@ return function drop(options = {}) { | ||
// Multiple actions are dispatched here, which is why this doesn't return an action | ||
targetIds.forEach((targetId, index) => { | ||
targetIds.forEach((targetId, index)=>{ | ||
const dropResult = determineDropResult(targetId, index, registry, monitor); | ||
const action = { | ||
type: types_1.DROP, | ||
type: _types.DROP, | ||
payload: { | ||
dropResult: { | ||
...options, | ||
...dropResult, | ||
}, | ||
}, | ||
dropResult: _objectSpread({}, options, dropResult) | ||
} | ||
}; | ||
@@ -30,6 +57,5 @@ manager.dispatch(action); | ||
} | ||
exports.createDrop = createDrop; | ||
function verifyInvariants(monitor) { | ||
(0, invariant_1.invariant)(monitor.isDragging(), 'Cannot call drop while not dragging.'); | ||
(0, invariant_1.invariant)(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.'); | ||
(0, _invariant).invariant(monitor.isDragging(), 'Cannot call drop while not dragging.'); | ||
(0, _invariant).invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.'); | ||
} | ||
@@ -46,10 +72,10 @@ function determineDropResult(targetId, index, registry, monitor) { | ||
function verifyDropResultType(dropResult) { | ||
(0, invariant_1.invariant)(typeof dropResult === 'undefined' || (0, js_utils_1.isObject)(dropResult), 'Drop result must either be an object or undefined.'); | ||
(0, _invariant).invariant(typeof dropResult === 'undefined' || (0, _jsUtils).isObject(dropResult), 'Drop result must either be an object or undefined.'); | ||
} | ||
function getDroppableTargets(monitor) { | ||
const targetIds = monitor | ||
.getTargetIds() | ||
.filter(monitor.canDropOnTarget, monitor); | ||
const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor); | ||
targetIds.reverse(); | ||
return targetIds; | ||
} | ||
//# sourceMappingURL=drop.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createEndDrag = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
const types_1 = require("./types"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createEndDrag = createEndDrag; | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _types = require("./types"); | ||
function createEndDrag(manager) { | ||
@@ -17,8 +19,11 @@ return function endDrag() { | ||
} | ||
return { type: types_1.END_DRAG }; | ||
return { | ||
type: _types.END_DRAG | ||
}; | ||
}; | ||
} | ||
exports.createEndDrag = createEndDrag; | ||
function verifyIsDragging(monitor) { | ||
(0, invariant_1.invariant)(monitor.isDragging(), 'Cannot call endDrag while not dragging.'); | ||
(0, _invariant).invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.'); | ||
} | ||
//# sourceMappingURL=endDrag.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createHover = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
const matchesType_1 = require("../../utils/matchesType"); | ||
const types_1 = require("./types"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createHover = createHover; | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _matchesType = require("../../utils/matchesType"); | ||
var _types = require("./types"); | ||
function createHover(manager) { | ||
return function hover(targetIdsArg, { clientOffset } = {}) { | ||
return function hover(targetIdsArg, { clientOffset } = {}) { | ||
verifyTargetIdsIsArray(targetIdsArg); | ||
@@ -18,22 +20,21 @@ const targetIds = targetIdsArg.slice(0); | ||
return { | ||
type: types_1.HOVER, | ||
type: _types.HOVER, | ||
payload: { | ||
targetIds, | ||
clientOffset: clientOffset || null, | ||
}, | ||
clientOffset: clientOffset || null | ||
} | ||
}; | ||
}; | ||
} | ||
exports.createHover = createHover; | ||
function verifyTargetIdsIsArray(targetIdsArg) { | ||
(0, invariant_1.invariant)(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.'); | ||
(0, _invariant).invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.'); | ||
} | ||
function checkInvariants(targetIds, monitor, registry) { | ||
(0, invariant_1.invariant)(monitor.isDragging(), 'Cannot call hover while not dragging.'); | ||
(0, invariant_1.invariant)(!monitor.didDrop(), 'Cannot call hover after drop.'); | ||
for (let i = 0; i < targetIds.length; i++) { | ||
(0, _invariant).invariant(monitor.isDragging(), 'Cannot call hover while not dragging.'); | ||
(0, _invariant).invariant(!monitor.didDrop(), 'Cannot call hover after drop.'); | ||
for(let i = 0; i < targetIds.length; i++){ | ||
const targetId = targetIds[i]; | ||
(0, invariant_1.invariant)(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.'); | ||
(0, _invariant).invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.'); | ||
const target = registry.getTarget(targetId); | ||
(0, invariant_1.invariant)(target, 'Expected targetIds to be registered.'); | ||
(0, _invariant).invariant(target, 'Expected targetIds to be registered.'); | ||
} | ||
@@ -45,6 +46,6 @@ } | ||
// non-matching targets. | ||
for (let i = targetIds.length - 1; i >= 0; i--) { | ||
for(let i = targetIds.length - 1; i >= 0; i--){ | ||
const targetId = targetIds[i]; | ||
const targetType = registry.getTargetType(targetId); | ||
if (!(0, matchesType_1.matchesType)(targetType, draggedItemType)) { | ||
if (!(0, _matchesType).matchesType(targetType, draggedItemType)) { | ||
targetIds.splice(i, 1); | ||
@@ -56,3 +57,3 @@ } | ||
// Finally call hover on all matching targets. | ||
targetIds.forEach(function (targetId) { | ||
targetIds.forEach(function(targetId) { | ||
const target = registry.getTarget(targetId); | ||
@@ -62,1 +63,3 @@ target.hover(monitor, targetId); | ||
} | ||
//# sourceMappingURL=hover.js.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDragDropActions = void 0; | ||
const beginDrag_1 = require("./beginDrag"); | ||
const publishDragSource_1 = require("./publishDragSource"); | ||
const hover_1 = require("./hover"); | ||
const drop_1 = require("./drop"); | ||
const endDrag_1 = require("./endDrag"); | ||
__exportStar(require("./types"), exports); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createDragDropActions = createDragDropActions; | ||
var _beginDrag = require("./beginDrag"); | ||
var _publishDragSource = require("./publishDragSource"); | ||
var _hover = require("./hover"); | ||
var _drop = require("./drop"); | ||
var _endDrag = require("./endDrag"); | ||
var _types = _interopRequireWildcard(require("./types")); | ||
Object.keys(_types).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _types[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _types[key]; | ||
} | ||
}); | ||
}); | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = {}; | ||
if (obj != null) { | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
function createDragDropActions(manager) { | ||
return { | ||
beginDrag: (0, beginDrag_1.createBeginDrag)(manager), | ||
publishDragSource: (0, publishDragSource_1.createPublishDragSource)(manager), | ||
hover: (0, hover_1.createHover)(manager), | ||
drop: (0, drop_1.createDrop)(manager), | ||
endDrag: (0, endDrag_1.createEndDrag)(manager), | ||
beginDrag: (0, _beginDrag).createBeginDrag(manager), | ||
publishDragSource: (0, _publishDragSource).createPublishDragSource(manager), | ||
hover: (0, _hover).createHover(manager), | ||
drop: (0, _drop).createDrop(manager), | ||
endDrag: (0, _endDrag).createEndDrag(manager) | ||
}; | ||
} | ||
exports.createDragDropActions = createDragDropActions; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setClientOffset = void 0; | ||
const types_1 = require("../types"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.setClientOffset = setClientOffset; | ||
var _types = require("../types"); | ||
function setClientOffset(clientOffset, sourceClientOffset) { | ||
return { | ||
type: types_1.INIT_COORDS, | ||
type: _types.INIT_COORDS, | ||
payload: { | ||
sourceClientOffset: sourceClientOffset || null, | ||
clientOffset: clientOffset || null, | ||
}, | ||
clientOffset: clientOffset || null | ||
} | ||
}; | ||
} | ||
exports.setClientOffset = setClientOffset; | ||
//# sourceMappingURL=setClientOffset.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createPublishDragSource = void 0; | ||
const types_1 = require("./types"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createPublishDragSource = createPublishDragSource; | ||
var _types = require("./types"); | ||
function createPublishDragSource(manager) { | ||
@@ -9,3 +11,5 @@ return function publishDragSource() { | ||
if (monitor.isDragging()) { | ||
return { type: types_1.PUBLISH_DRAG_SOURCE }; | ||
return { | ||
type: _types.PUBLISH_DRAG_SOURCE | ||
}; | ||
} | ||
@@ -15,2 +19,3 @@ return; | ||
} | ||
exports.createPublishDragSource = createPublishDragSource; | ||
//# sourceMappingURL=publishDragSource.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.END_DRAG = exports.DROP = exports.HOVER = exports.PUBLISH_DRAG_SOURCE = exports.BEGIN_DRAG = exports.INIT_COORDS = void 0; | ||
exports.INIT_COORDS = 'dnd-core/INIT_COORDS'; | ||
exports.BEGIN_DRAG = 'dnd-core/BEGIN_DRAG'; | ||
exports.PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE'; | ||
exports.HOVER = 'dnd-core/HOVER'; | ||
exports.DROP = 'dnd-core/DROP'; | ||
exports.END_DRAG = 'dnd-core/END_DRAG'; | ||
const INIT_COORDS = 'dnd-core/INIT_COORDS'; | ||
exports.INIT_COORDS = INIT_COORDS; | ||
const BEGIN_DRAG = 'dnd-core/BEGIN_DRAG'; | ||
exports.BEGIN_DRAG = BEGIN_DRAG; | ||
const PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE'; | ||
exports.PUBLISH_DRAG_SOURCE = PUBLISH_DRAG_SOURCE; | ||
const HOVER = 'dnd-core/HOVER'; | ||
exports.HOVER = HOVER; | ||
const DROP = 'dnd-core/DROP'; | ||
exports.DROP = DROP; | ||
const END_DRAG = 'dnd-core/END_DRAG'; | ||
exports.END_DRAG = END_DRAG; | ||
//# sourceMappingURL=types.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeTarget = exports.removeSource = exports.addTarget = exports.addSource = exports.REMOVE_TARGET = exports.REMOVE_SOURCE = exports.ADD_TARGET = exports.ADD_SOURCE = void 0; | ||
exports.ADD_SOURCE = 'dnd-core/ADD_SOURCE'; | ||
exports.ADD_TARGET = 'dnd-core/ADD_TARGET'; | ||
exports.REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE'; | ||
exports.REMOVE_TARGET = 'dnd-core/REMOVE_TARGET'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.addSource = addSource; | ||
exports.addTarget = addTarget; | ||
exports.removeSource = removeSource; | ||
exports.removeTarget = removeTarget; | ||
exports.REMOVE_TARGET = exports.REMOVE_SOURCE = exports.ADD_TARGET = exports.ADD_SOURCE = void 0; | ||
const ADD_SOURCE = 'dnd-core/ADD_SOURCE'; | ||
exports.ADD_SOURCE = ADD_SOURCE; | ||
const ADD_TARGET = 'dnd-core/ADD_TARGET'; | ||
exports.ADD_TARGET = ADD_TARGET; | ||
const REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE'; | ||
exports.REMOVE_SOURCE = REMOVE_SOURCE; | ||
const REMOVE_TARGET = 'dnd-core/REMOVE_TARGET'; | ||
exports.REMOVE_TARGET = REMOVE_TARGET; | ||
function addSource(sourceId) { | ||
return { | ||
type: exports.ADD_SOURCE, | ||
type: ADD_SOURCE, | ||
payload: { | ||
sourceId, | ||
}, | ||
sourceId | ||
} | ||
}; | ||
} | ||
exports.addSource = addSource; | ||
function addTarget(targetId) { | ||
return { | ||
type: exports.ADD_TARGET, | ||
type: ADD_TARGET, | ||
payload: { | ||
targetId, | ||
}, | ||
targetId | ||
} | ||
}; | ||
} | ||
exports.addTarget = addTarget; | ||
function removeSource(sourceId) { | ||
return { | ||
type: exports.REMOVE_SOURCE, | ||
type: REMOVE_SOURCE, | ||
payload: { | ||
sourceId, | ||
}, | ||
sourceId | ||
} | ||
}; | ||
} | ||
exports.removeSource = removeSource; | ||
function removeTarget(targetId) { | ||
return { | ||
type: exports.REMOVE_TARGET, | ||
type: REMOVE_TARGET, | ||
payload: { | ||
targetId, | ||
}, | ||
targetId | ||
} | ||
}; | ||
} | ||
exports.removeTarget = removeTarget; | ||
//# sourceMappingURL=registry.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DragDropManagerImpl = void 0; | ||
const dragDrop_1 = require("../actions/dragDrop"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _dragDrop = require("../actions/dragDrop"); | ||
class DragDropManagerImpl { | ||
store; | ||
monitor; | ||
backend; | ||
isSetUp = false; | ||
constructor(store, monitor) { | ||
this.store = store; | ||
this.monitor = monitor; | ||
store.subscribe(this.handleRefCountChange); | ||
} | ||
receiveBackend(backend) { | ||
@@ -28,7 +20,6 @@ this.backend = backend; | ||
getActions() { | ||
/* eslint-disable-next-line @typescript-eslint/no-this-alias */ | ||
const manager = this; | ||
const { dispatch } = this.store; | ||
/* eslint-disable-next-line @typescript-eslint/no-this-alias */ const manager = this; | ||
const { dispatch } = this.store; | ||
function bindActionCreator(actionCreator) { | ||
return (...args) => { | ||
return (...args)=>{ | ||
const action = actionCreator.apply(manager, args); | ||
@@ -40,4 +31,4 @@ if (typeof action !== 'undefined') { | ||
} | ||
const actions = (0, dragDrop_1.createDragDropActions)(this); | ||
return Object.keys(actions).reduce((boundActions, key) => { | ||
const actions = (0, _dragDrop).createDragDropActions(this); | ||
return Object.keys(actions).reduce((boundActions, key)=>{ | ||
const action = actions[key]; | ||
@@ -51,16 +42,23 @@ boundActions[key] = bindActionCreator(action); | ||
} | ||
handleRefCountChange = () => { | ||
const shouldSetUp = this.store.getState().refCount > 0; | ||
if (this.backend) { | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
constructor(store, monitor){ | ||
this.isSetUp = false; | ||
this.handleRefCountChange = ()=>{ | ||
const shouldSetUp = this.store.getState().refCount > 0; | ||
if (this.backend) { | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
} else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
} | ||
else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
} | ||
}; | ||
}; | ||
this.store = store; | ||
this.monitor = monitor; | ||
store.subscribe(this.handleRefCountChange); | ||
} | ||
} | ||
exports.DragDropManagerImpl = DragDropManagerImpl; | ||
//# sourceMappingURL=DragDropManagerImpl.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DragDropMonitorImpl = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
const matchesType_1 = require("../utils/matchesType"); | ||
const coords_1 = require("../utils/coords"); | ||
const dirtiness_1 = require("../utils/dirtiness"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _matchesType = require("../utils/matchesType"); | ||
var _coords = require("../utils/coords"); | ||
var _dirtiness = require("../utils/dirtiness"); | ||
class DragDropMonitorImpl { | ||
store; | ||
registry; | ||
constructor(store, registry) { | ||
this.store = store; | ||
this.registry = registry; | ||
} | ||
subscribeToStateChange(listener, options = {}) { | ||
const { handlerIds } = options; | ||
(0, invariant_1.invariant)(typeof listener === 'function', 'listener must be a function.'); | ||
(0, invariant_1.invariant)(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.'); | ||
const { handlerIds } = options; | ||
(0, _invariant).invariant(typeof listener === 'function', 'listener must be a function.'); | ||
(0, _invariant).invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.'); | ||
let prevStateId = this.store.getState().stateId; | ||
const handleChange = () => { | ||
const handleChange = ()=>{ | ||
const state = this.store.getState(); | ||
const currentStateId = state.stateId; | ||
try { | ||
const canSkipListener = currentStateId === prevStateId || | ||
(currentStateId === prevStateId + 1 && | ||
!(0, dirtiness_1.areDirty)(state.dirtyHandlerIds, handlerIds)); | ||
const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !(0, _dirtiness).areDirty(state.dirtyHandlerIds, handlerIds); | ||
if (!canSkipListener) { | ||
listener(); | ||
} | ||
} | ||
finally { | ||
} finally{ | ||
prevStateId = currentStateId; | ||
@@ -38,5 +30,5 @@ } | ||
subscribeToOffsetChange(listener) { | ||
(0, invariant_1.invariant)(typeof listener === 'function', 'listener must be a function.'); | ||
(0, _invariant).invariant(typeof listener === 'function', 'listener must be a function.'); | ||
let previousState = this.store.getState().dragOffset; | ||
const handleChange = () => { | ||
const handleChange = ()=>{ | ||
const nextState = this.store.getState().dragOffset; | ||
@@ -56,3 +48,3 @@ if (nextState === previousState) { | ||
const source = this.registry.getSource(sourceId); | ||
(0, invariant_1.invariant)(source, `Expected to find a valid source. sourceId=${sourceId}`); | ||
(0, _invariant).invariant(source, `Expected to find a valid source. sourceId=${sourceId}`); | ||
if (this.isDragging()) { | ||
@@ -69,3 +61,3 @@ return false; | ||
const target = this.registry.getTarget(targetId); | ||
(0, invariant_1.invariant)(target, `Expected to find a valid target. targetId=${targetId}`); | ||
(0, _invariant).invariant(target, `Expected to find a valid target. targetId=${targetId}`); | ||
if (!this.isDragging() || this.didDrop()) { | ||
@@ -76,3 +68,3 @@ return false; | ||
const draggedItemType = this.getItemType(); | ||
return ((0, matchesType_1.matchesType)(targetType, draggedItemType) && target.canDrop(this, targetId)); | ||
return (0, _matchesType).matchesType(targetType, draggedItemType) && target.canDrop(this, targetId); | ||
} | ||
@@ -88,3 +80,3 @@ isDragging() { | ||
const source = this.registry.getSource(sourceId, true); | ||
(0, invariant_1.invariant)(source, `Expected to find a valid source. sourceId=${sourceId}`); | ||
(0, _invariant).invariant(source, `Expected to find a valid source. sourceId=${sourceId}`); | ||
if (!this.isDragging() || !this.isSourcePublic()) { | ||
@@ -100,3 +92,5 @@ return false; | ||
} | ||
isOverTarget(targetId, options = { shallow: false }) { | ||
isOverTarget(targetId, options = { | ||
shallow: false | ||
}) { | ||
// undefined on initial render | ||
@@ -106,3 +100,3 @@ if (!targetId) { | ||
} | ||
const { shallow } = options; | ||
const { shallow } = options; | ||
if (!this.isDragging()) { | ||
@@ -113,3 +107,3 @@ return false; | ||
const draggedItemType = this.getItemType(); | ||
if (draggedItemType && !(0, matchesType_1.matchesType)(targetType, draggedItemType)) { | ||
if (draggedItemType && !(0, _matchesType).matchesType(targetType, draggedItemType)) { | ||
return false; | ||
@@ -124,4 +118,3 @@ } | ||
return index === targetIds.length - 1; | ||
} | ||
else { | ||
} else { | ||
return index > -1; | ||
@@ -161,8 +154,14 @@ } | ||
getSourceClientOffset() { | ||
return (0, coords_1.getSourceClientOffset)(this.store.getState().dragOffset); | ||
return (0, _coords).getSourceClientOffset(this.store.getState().dragOffset); | ||
} | ||
getDifferenceFromInitialOffset() { | ||
return (0, coords_1.getDifferenceFromInitialOffset)(this.store.getState().dragOffset); | ||
return (0, _coords).getDifferenceFromInitialOffset(this.store.getState().dragOffset); | ||
} | ||
constructor(store, registry){ | ||
this.store = store; | ||
this.registry = registry; | ||
} | ||
} | ||
exports.DragDropMonitorImpl = DragDropMonitorImpl; | ||
//# sourceMappingURL=DragDropMonitorImpl.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HandlerRegistryImpl = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
const registry_1 = require("../actions/registry"); | ||
const getNextUniqueId_1 = require("../utils/getNextUniqueId"); | ||
const interfaces_1 = require("../interfaces"); | ||
const contracts_1 = require("../contracts"); | ||
const asap_1 = require("@react-dnd/asap"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _registry = require("../actions/registry"); | ||
var _getNextUniqueId = require("../utils/getNextUniqueId"); | ||
var _interfaces = require("../interfaces"); | ||
var _contracts = require("../contracts"); | ||
var _asap = require("@react-dnd/asap"); | ||
function getNextHandlerId(role) { | ||
const id = (0, getNextUniqueId_1.getNextUniqueId)().toString(); | ||
switch (role) { | ||
case interfaces_1.HandlerRole.SOURCE: | ||
const id = (0, _getNextUniqueId).getNextUniqueId().toString(); | ||
switch(role){ | ||
case _interfaces.HandlerRole.SOURCE: | ||
return `S${id}`; | ||
case interfaces_1.HandlerRole.TARGET: | ||
case _interfaces.HandlerRole.TARGET: | ||
return `T${id}`; | ||
@@ -22,7 +23,7 @@ default: | ||
function parseRoleFromHandlerId(handlerId) { | ||
switch (handlerId[0]) { | ||
switch(handlerId[0]){ | ||
case 'S': | ||
return interfaces_1.HandlerRole.SOURCE; | ||
return _interfaces.HandlerRole.SOURCE; | ||
case 'T': | ||
return interfaces_1.HandlerRole.TARGET; | ||
return _interfaces.HandlerRole.TARGET; | ||
default: | ||
@@ -36,3 +37,3 @@ throw new Error(`Cannot parse handler ID: ${handlerId}`); | ||
do { | ||
const { done, value: [, value], } = entries.next(); | ||
const { done , value: [, value] , } = entries.next(); | ||
if (value === searchValue) { | ||
@@ -42,35 +43,25 @@ return true; | ||
isDone = !!done; | ||
} while (!isDone); | ||
}while (!isDone) | ||
return false; | ||
} | ||
class HandlerRegistryImpl { | ||
types = new Map(); | ||
dragSources = new Map(); | ||
dropTargets = new Map(); | ||
pinnedSourceId = null; | ||
pinnedSource = null; | ||
store; | ||
constructor(store) { | ||
this.store = store; | ||
} | ||
addSource(type, source) { | ||
(0, contracts_1.validateType)(type); | ||
(0, contracts_1.validateSourceContract)(source); | ||
const sourceId = this.addHandler(interfaces_1.HandlerRole.SOURCE, type, source); | ||
this.store.dispatch((0, registry_1.addSource)(sourceId)); | ||
(0, _contracts).validateType(type); | ||
(0, _contracts).validateSourceContract(source); | ||
const sourceId = this.addHandler(_interfaces.HandlerRole.SOURCE, type, source); | ||
this.store.dispatch((0, _registry).addSource(sourceId)); | ||
return sourceId; | ||
} | ||
addTarget(type, target) { | ||
(0, contracts_1.validateType)(type, true); | ||
(0, contracts_1.validateTargetContract)(target); | ||
const targetId = this.addHandler(interfaces_1.HandlerRole.TARGET, type, target); | ||
this.store.dispatch((0, registry_1.addTarget)(targetId)); | ||
(0, _contracts).validateType(type, true); | ||
(0, _contracts).validateTargetContract(target); | ||
const targetId = this.addHandler(_interfaces.HandlerRole.TARGET, type, target); | ||
this.store.dispatch((0, _registry).addTarget(targetId)); | ||
return targetId; | ||
} | ||
containsHandler(handler) { | ||
return (mapContainsValue(this.dragSources, handler) || | ||
mapContainsValue(this.dropTargets, handler)); | ||
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler); | ||
} | ||
getSource(sourceId, includePinned = false) { | ||
(0, invariant_1.invariant)(this.isSourceId(sourceId), 'Expected a valid source ID.'); | ||
(0, _invariant).invariant(this.isSourceId(sourceId), 'Expected a valid source ID.'); | ||
const isPinned = includePinned && sourceId === this.pinnedSourceId; | ||
@@ -81,11 +72,11 @@ const source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId); | ||
getTarget(targetId) { | ||
(0, invariant_1.invariant)(this.isTargetId(targetId), 'Expected a valid target ID.'); | ||
(0, _invariant).invariant(this.isTargetId(targetId), 'Expected a valid target ID.'); | ||
return this.dropTargets.get(targetId); | ||
} | ||
getSourceType(sourceId) { | ||
(0, invariant_1.invariant)(this.isSourceId(sourceId), 'Expected a valid source ID.'); | ||
(0, _invariant).invariant(this.isSourceId(sourceId), 'Expected a valid source ID.'); | ||
return this.types.get(sourceId); | ||
} | ||
getTargetType(targetId) { | ||
(0, invariant_1.invariant)(this.isTargetId(targetId), 'Expected a valid target ID.'); | ||
(0, _invariant).invariant(this.isTargetId(targetId), 'Expected a valid target ID.'); | ||
return this.types.get(targetId); | ||
@@ -95,12 +86,12 @@ } | ||
const role = parseRoleFromHandlerId(handlerId); | ||
return role === interfaces_1.HandlerRole.SOURCE; | ||
return role === _interfaces.HandlerRole.SOURCE; | ||
} | ||
isTargetId(handlerId) { | ||
const role = parseRoleFromHandlerId(handlerId); | ||
return role === interfaces_1.HandlerRole.TARGET; | ||
return role === _interfaces.HandlerRole.TARGET; | ||
} | ||
removeSource(sourceId) { | ||
(0, invariant_1.invariant)(this.getSource(sourceId), 'Expected an existing source.'); | ||
this.store.dispatch((0, registry_1.removeSource)(sourceId)); | ||
(0, asap_1.asap)(() => { | ||
(0, _invariant).invariant(this.getSource(sourceId), 'Expected an existing source.'); | ||
this.store.dispatch((0, _registry).removeSource(sourceId)); | ||
(0, _asap).asap(()=>{ | ||
this.dragSources.delete(sourceId); | ||
@@ -111,4 +102,4 @@ this.types.delete(sourceId); | ||
removeTarget(targetId) { | ||
(0, invariant_1.invariant)(this.getTarget(targetId), 'Expected an existing target.'); | ||
this.store.dispatch((0, registry_1.removeTarget)(targetId)); | ||
(0, _invariant).invariant(this.getTarget(targetId), 'Expected an existing target.'); | ||
this.store.dispatch((0, _registry).removeTarget(targetId)); | ||
this.dropTargets.delete(targetId); | ||
@@ -119,3 +110,3 @@ this.types.delete(targetId); | ||
const source = this.getSource(sourceId); | ||
(0, invariant_1.invariant)(source, 'Expected an existing source.'); | ||
(0, _invariant).invariant(source, 'Expected an existing source.'); | ||
this.pinnedSourceId = sourceId; | ||
@@ -125,3 +116,3 @@ this.pinnedSource = source; | ||
unpinSource() { | ||
(0, invariant_1.invariant)(this.pinnedSource, 'No source is pinned at the time.'); | ||
(0, _invariant).invariant(this.pinnedSource, 'No source is pinned at the time.'); | ||
this.pinnedSourceId = null; | ||
@@ -133,6 +124,5 @@ this.pinnedSource = null; | ||
this.types.set(id, type); | ||
if (role === interfaces_1.HandlerRole.SOURCE) { | ||
if (role === _interfaces.HandlerRole.SOURCE) { | ||
this.dragSources.set(id, handler); | ||
} | ||
else if (role === interfaces_1.HandlerRole.TARGET) { | ||
} else if (role === _interfaces.HandlerRole.TARGET) { | ||
this.dropTargets.set(id, handler); | ||
@@ -142,3 +132,13 @@ } | ||
} | ||
constructor(store){ | ||
this.types = new Map(); | ||
this.dragSources = new Map(); | ||
this.dropTargets = new Map(); | ||
this.pinnedSourceId = null; | ||
this.pinnedSource = null; | ||
this.store = store; | ||
} | ||
} | ||
exports.HandlerRegistryImpl = HandlerRegistryImpl; | ||
//# sourceMappingURL=HandlerRegistryImpl.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateType = exports.validateTargetContract = exports.validateSourceContract = void 0; | ||
const invariant_1 = require("@react-dnd/invariant"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.validateSourceContract = validateSourceContract; | ||
exports.validateTargetContract = validateTargetContract; | ||
exports.validateType = validateType; | ||
var _invariant = require("@react-dnd/invariant"); | ||
function validateSourceContract(source) { | ||
(0, invariant_1.invariant)(typeof source.canDrag === 'function', 'Expected canDrag to be a function.'); | ||
(0, invariant_1.invariant)(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.'); | ||
(0, invariant_1.invariant)(typeof source.endDrag === 'function', 'Expected endDrag to be a function.'); | ||
(0, _invariant).invariant(typeof source.canDrag === 'function', 'Expected canDrag to be a function.'); | ||
(0, _invariant).invariant(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.'); | ||
(0, _invariant).invariant(typeof source.endDrag === 'function', 'Expected endDrag to be a function.'); | ||
} | ||
exports.validateSourceContract = validateSourceContract; | ||
function validateTargetContract(target) { | ||
(0, invariant_1.invariant)(typeof target.canDrop === 'function', 'Expected canDrop to be a function.'); | ||
(0, invariant_1.invariant)(typeof target.hover === 'function', 'Expected hover to be a function.'); | ||
(0, invariant_1.invariant)(typeof target.drop === 'function', 'Expected beginDrag to be a function.'); | ||
(0, _invariant).invariant(typeof target.canDrop === 'function', 'Expected canDrop to be a function.'); | ||
(0, _invariant).invariant(typeof target.hover === 'function', 'Expected hover to be a function.'); | ||
(0, _invariant).invariant(typeof target.drop === 'function', 'Expected beginDrag to be a function.'); | ||
} | ||
exports.validateTargetContract = validateTargetContract; | ||
function validateType(type, allowArray) { | ||
if (allowArray && Array.isArray(type)) { | ||
type.forEach((t) => validateType(t, false)); | ||
type.forEach((t)=>validateType(t, false) | ||
); | ||
return; | ||
} | ||
(0, invariant_1.invariant)(typeof type === 'string' || typeof type === 'symbol', allowArray | ||
? 'Type can only be a string, a symbol, or an array of either.' | ||
: 'Type can only be a string or a symbol.'); | ||
(0, _invariant).invariant(typeof type === 'string' || typeof type === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.'); | ||
} | ||
exports.validateType = validateType; | ||
//# sourceMappingURL=contracts.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDragDropManager = void 0; | ||
const DragDropManagerImpl_1 = require("./classes/DragDropManagerImpl"); | ||
const redux_1 = require("redux"); | ||
const reducers_1 = require("./reducers"); | ||
const DragDropMonitorImpl_1 = require("./classes/DragDropMonitorImpl"); | ||
const HandlerRegistryImpl_1 = require("./classes/HandlerRegistryImpl"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createDragDropManager = createDragDropManager; | ||
var _dragDropManagerImpl = require("./classes/DragDropManagerImpl"); | ||
var _redux = require("redux"); | ||
var _reducers = require("./reducers"); | ||
var _dragDropMonitorImpl = require("./classes/DragDropMonitorImpl"); | ||
var _handlerRegistryImpl = require("./classes/HandlerRegistryImpl"); | ||
function createDragDropManager(backendFactory, globalContext = undefined, backendOptions = {}, debugMode = false) { | ||
const store = makeStoreInstance(debugMode); | ||
const monitor = new DragDropMonitorImpl_1.DragDropMonitorImpl(store, new HandlerRegistryImpl_1.HandlerRegistryImpl(store)); | ||
const manager = new DragDropManagerImpl_1.DragDropManagerImpl(store, monitor); | ||
const monitor = new _dragDropMonitorImpl.DragDropMonitorImpl(store, new _handlerRegistryImpl.HandlerRegistryImpl(store)); | ||
const manager = new _dragDropManagerImpl.DragDropManagerImpl(store, monitor); | ||
const backend = backendFactory(manager, globalContext, backendOptions); | ||
@@ -17,14 +19,12 @@ manager.receiveBackend(backend); | ||
} | ||
exports.createDragDropManager = createDragDropManager; | ||
function makeStoreInstance(debugMode) { | ||
// TODO: if we ever make a react-native version of this, | ||
// we'll need to consider how to pull off dev-tooling | ||
const reduxDevTools = typeof window !== 'undefined' && | ||
window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return (0, redux_1.createStore)(reducers_1.reduce, debugMode && | ||
reduxDevTools && | ||
reduxDevTools({ | ||
name: 'dnd-core', | ||
instanceId: 'dnd-core', | ||
})); | ||
const reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return (0, _redux).createStore(_reducers.reduce, debugMode && reduxDevTools && reduxDevTools({ | ||
name: 'dnd-core', | ||
instanceId: 'dnd-core' | ||
})); | ||
} | ||
//# sourceMappingURL=createDragDropManager.js.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./interfaces"), exports); | ||
__exportStar(require("./createDragDropManager"), exports); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _exportNames = {}; | ||
var _interfaces = _interopRequireWildcard(require("./interfaces")); | ||
Object.keys(_interfaces).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _interfaces[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _interfaces[key]; | ||
} | ||
}); | ||
}); | ||
var _createDragDropManager = _interopRequireWildcard(require("./createDragDropManager")); | ||
Object.keys(_createDragDropManager).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _createDragDropManager[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _createDragDropManager[key]; | ||
} | ||
}); | ||
}); | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = {}; | ||
if (obj != null) { | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.HandlerRole = void 0; | ||
var HandlerRole; | ||
(function (HandlerRole) { | ||
exports.HandlerRole = HandlerRole; | ||
(function(HandlerRole) { | ||
HandlerRole["SOURCE"] = "SOURCE"; | ||
HandlerRole["TARGET"] = "TARGET"; | ||
})(HandlerRole = exports.HandlerRole || (exports.HandlerRole = {})); | ||
})(HandlerRole || (exports.HandlerRole = HandlerRole = {})); | ||
//# sourceMappingURL=interfaces.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reduce = void 0; | ||
const dragDrop_1 = require("../actions/dragDrop"); | ||
const registry_1 = require("../actions/registry"); | ||
const equality_1 = require("../utils/equality"); | ||
const dirtiness_1 = require("../utils/dirtiness"); | ||
const js_utils_1 = require("../utils/js_utils"); | ||
function reduce( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_state = dirtiness_1.NONE, action) { | ||
switch (action.type) { | ||
case dragDrop_1.HOVER: | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reduce = reduce; | ||
var _dragDrop = require("../actions/dragDrop"); | ||
var _registry = require("../actions/registry"); | ||
var _equality = require("../utils/equality"); | ||
var _dirtiness = require("../utils/dirtiness"); | ||
var _jsUtils = require("../utils/js_utils"); | ||
function reduce(// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_state = _dirtiness.NONE, action) { | ||
switch(action.type){ | ||
case _dragDrop.HOVER: | ||
break; | ||
case registry_1.ADD_SOURCE: | ||
case registry_1.ADD_TARGET: | ||
case registry_1.REMOVE_TARGET: | ||
case registry_1.REMOVE_SOURCE: | ||
return dirtiness_1.NONE; | ||
case dragDrop_1.BEGIN_DRAG: | ||
case dragDrop_1.PUBLISH_DRAG_SOURCE: | ||
case dragDrop_1.END_DRAG: | ||
case dragDrop_1.DROP: | ||
case _registry.ADD_SOURCE: | ||
case _registry.ADD_TARGET: | ||
case _registry.REMOVE_TARGET: | ||
case _registry.REMOVE_SOURCE: | ||
return _dirtiness.NONE; | ||
case _dragDrop.BEGIN_DRAG: | ||
case _dragDrop.PUBLISH_DRAG_SOURCE: | ||
case _dragDrop.END_DRAG: | ||
case _dragDrop.DROP: | ||
default: | ||
return dirtiness_1.ALL; | ||
return _dirtiness.ALL; | ||
} | ||
const { targetIds = [], prevTargetIds = [] } = action.payload; | ||
const result = (0, js_utils_1.xor)(targetIds, prevTargetIds); | ||
const didChange = result.length > 0 || !(0, equality_1.areArraysEqual)(targetIds, prevTargetIds); | ||
const { targetIds =[] , prevTargetIds =[] } = action.payload; | ||
const result = (0, _jsUtils).xor(targetIds, prevTargetIds); | ||
const didChange = result.length > 0 || !(0, _equality).areArraysEqual(targetIds, prevTargetIds); | ||
if (!didChange) { | ||
return dirtiness_1.NONE; | ||
return _dirtiness.NONE; | ||
} | ||
@@ -47,2 +48,3 @@ // Check the target ids at the innermost position. If they are valid, add them | ||
} | ||
exports.reduce = reduce; | ||
//# sourceMappingURL=dirtyHandlerIds.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reduce = void 0; | ||
const dragDrop_1 = require("../actions/dragDrop"); | ||
const equality_1 = require("../utils/equality"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reduce = reduce; | ||
var _dragDrop = require("../actions/dragDrop"); | ||
var _equality = require("../utils/equality"); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
const initialState = { | ||
initialSourceClientOffset: null, | ||
initialClientOffset: null, | ||
clientOffset: null, | ||
clientOffset: null | ||
}; | ||
function reduce(state = initialState, action) { | ||
const { payload } = action; | ||
switch (action.type) { | ||
case dragDrop_1.INIT_COORDS: | ||
case dragDrop_1.BEGIN_DRAG: | ||
const { payload } = action; | ||
switch(action.type){ | ||
case _dragDrop.INIT_COORDS: | ||
case _dragDrop.BEGIN_DRAG: | ||
return { | ||
initialSourceClientOffset: payload.sourceClientOffset, | ||
initialClientOffset: payload.clientOffset, | ||
clientOffset: payload.clientOffset, | ||
clientOffset: payload.clientOffset | ||
}; | ||
case dragDrop_1.HOVER: | ||
if ((0, equality_1.areCoordsEqual)(state.clientOffset, payload.clientOffset)) { | ||
case _dragDrop.HOVER: | ||
if ((0, _equality).areCoordsEqual(state.clientOffset, payload.clientOffset)) { | ||
return state; | ||
} | ||
return { | ||
...state, | ||
clientOffset: payload.clientOffset, | ||
}; | ||
case dragDrop_1.END_DRAG: | ||
case dragDrop_1.DROP: | ||
return _objectSpread({}, state, { | ||
clientOffset: payload.clientOffset | ||
}); | ||
case _dragDrop.END_DRAG: | ||
case _dragDrop.DROP: | ||
return initialState; | ||
@@ -36,2 +65,3 @@ default: | ||
} | ||
exports.reduce = reduce; | ||
//# sourceMappingURL=dragOffset.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reduce = void 0; | ||
const dragDrop_1 = require("../actions/dragDrop"); | ||
const registry_1 = require("../actions/registry"); | ||
const js_utils_1 = require("../utils/js_utils"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reduce = reduce; | ||
var _dragDrop = require("../actions/dragDrop"); | ||
var _registry = require("../actions/registry"); | ||
var _jsUtils = require("../utils/js_utils"); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
const initialState = { | ||
@@ -14,10 +44,9 @@ itemType: null, | ||
didDrop: false, | ||
isSourcePublic: null, | ||
isSourcePublic: null | ||
}; | ||
function reduce(state = initialState, action) { | ||
const { payload } = action; | ||
switch (action.type) { | ||
case dragDrop_1.BEGIN_DRAG: | ||
return { | ||
...state, | ||
const { payload } = action; | ||
switch(action.type){ | ||
case _dragDrop.BEGIN_DRAG: | ||
return _objectSpread({}, state, { | ||
itemType: payload.itemType, | ||
@@ -28,32 +57,27 @@ item: payload.item, | ||
dropResult: null, | ||
didDrop: false, | ||
}; | ||
case dragDrop_1.PUBLISH_DRAG_SOURCE: | ||
return { | ||
...state, | ||
isSourcePublic: true, | ||
}; | ||
case dragDrop_1.HOVER: | ||
return { | ||
...state, | ||
targetIds: payload.targetIds, | ||
}; | ||
case registry_1.REMOVE_TARGET: | ||
didDrop: false | ||
}); | ||
case _dragDrop.PUBLISH_DRAG_SOURCE: | ||
return _objectSpread({}, state, { | ||
isSourcePublic: true | ||
}); | ||
case _dragDrop.HOVER: | ||
return _objectSpread({}, state, { | ||
targetIds: payload.targetIds | ||
}); | ||
case _registry.REMOVE_TARGET: | ||
if (state.targetIds.indexOf(payload.targetId) === -1) { | ||
return state; | ||
} | ||
return { | ||
...state, | ||
targetIds: (0, js_utils_1.without)(state.targetIds, payload.targetId), | ||
}; | ||
case dragDrop_1.DROP: | ||
return { | ||
...state, | ||
return _objectSpread({}, state, { | ||
targetIds: (0, _jsUtils).without(state.targetIds, payload.targetId) | ||
}); | ||
case _dragDrop.DROP: | ||
return _objectSpread({}, state, { | ||
dropResult: payload.dropResult, | ||
didDrop: true, | ||
targetIds: [], | ||
}; | ||
case dragDrop_1.END_DRAG: | ||
return { | ||
...state, | ||
targetIds: [] | ||
}); | ||
case _dragDrop.END_DRAG: | ||
return _objectSpread({}, state, { | ||
itemType: null, | ||
@@ -65,4 +89,4 @@ item: null, | ||
isSourcePublic: null, | ||
targetIds: [], | ||
}; | ||
targetIds: [] | ||
}); | ||
default: | ||
@@ -72,2 +96,3 @@ return state; | ||
} | ||
exports.reduce = reduce; | ||
//# sourceMappingURL=dragOperation.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reduce = void 0; | ||
const dragOffset_1 = require("./dragOffset"); | ||
const dragOperation_1 = require("./dragOperation"); | ||
const refCount_1 = require("./refCount"); | ||
const dirtyHandlerIds_1 = require("./dirtyHandlerIds"); | ||
const stateId_1 = require("./stateId"); | ||
const js_utils_1 = require("../utils/js_utils"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reduce = reduce; | ||
var _dragOffset = require("./dragOffset"); | ||
var _dragOperation = require("./dragOperation"); | ||
var _refCount = require("./refCount"); | ||
var _dirtyHandlerIds = require("./dirtyHandlerIds"); | ||
var _stateId = require("./stateId"); | ||
var _jsUtils = require("../utils/js_utils"); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function reduce(state = {}, action) { | ||
return { | ||
dirtyHandlerIds: (0, dirtyHandlerIds_1.reduce)(state.dirtyHandlerIds, { | ||
dirtyHandlerIds: (0, _dirtyHandlerIds).reduce(state.dirtyHandlerIds, { | ||
type: action.type, | ||
payload: { | ||
...action.payload, | ||
prevTargetIds: (0, js_utils_1.get)(state, 'dragOperation.targetIds', []), | ||
}, | ||
payload: _objectSpread({}, action.payload, { | ||
prevTargetIds: (0, _jsUtils).get(state, 'dragOperation.targetIds', []) | ||
}) | ||
}), | ||
dragOffset: (0, dragOffset_1.reduce)(state.dragOffset, action), | ||
refCount: (0, refCount_1.reduce)(state.refCount, action), | ||
dragOperation: (0, dragOperation_1.reduce)(state.dragOperation, action), | ||
stateId: (0, stateId_1.reduce)(state.stateId), | ||
dragOffset: (0, _dragOffset).reduce(state.dragOffset, action), | ||
refCount: (0, _refCount).reduce(state.refCount, action), | ||
dragOperation: (0, _dragOperation).reduce(state.dragOperation, action), | ||
stateId: (0, _stateId).reduce(state.stateId) | ||
}; | ||
} | ||
exports.reduce = reduce; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reduce = void 0; | ||
const registry_1 = require("../actions/registry"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reduce = reduce; | ||
var _registry = require("../actions/registry"); | ||
function reduce(state = 0, action) { | ||
switch (action.type) { | ||
case registry_1.ADD_SOURCE: | ||
case registry_1.ADD_TARGET: | ||
switch(action.type){ | ||
case _registry.ADD_SOURCE: | ||
case _registry.ADD_TARGET: | ||
return state + 1; | ||
case registry_1.REMOVE_SOURCE: | ||
case registry_1.REMOVE_TARGET: | ||
case _registry.REMOVE_SOURCE: | ||
case _registry.REMOVE_TARGET: | ||
return state - 1; | ||
@@ -17,2 +19,3 @@ default: | ||
} | ||
exports.reduce = reduce; | ||
//# sourceMappingURL=refCount.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reduce = void 0; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reduce = reduce; | ||
function reduce(state = 0) { | ||
return state + 1; | ||
} | ||
exports.reduce = reduce; | ||
//# sourceMappingURL=stateId.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDifferenceFromInitialOffset = exports.getSourceClientOffset = exports.subtract = exports.add = void 0; | ||
/** | ||
* Coordinate addition | ||
* @param a The first coordinate | ||
* @param b The second coordinate | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.add = add; | ||
exports.subtract = subtract; | ||
exports.getSourceClientOffset = getSourceClientOffset; | ||
exports.getDifferenceFromInitialOffset = getDifferenceFromInitialOffset; | ||
function add(a, b) { | ||
return { | ||
x: a.x + b.x, | ||
y: a.y + b.y, | ||
y: a.y + b.y | ||
}; | ||
} | ||
exports.add = add; | ||
/** | ||
* Coordinate subtraction | ||
* @param a The first coordinate | ||
* @param b The second coordinate | ||
*/ | ||
function subtract(a, b) { | ||
return { | ||
x: a.x - b.x, | ||
y: a.y - b.y, | ||
y: a.y - b.y | ||
}; | ||
} | ||
exports.subtract = subtract; | ||
/** | ||
* Returns the cartesian distance of the drag source component's position, based on its position | ||
* at the time when the current drag operation has started, and the movement difference. | ||
* | ||
* Returns null if no item is being dragged. | ||
* | ||
* @param state The offset state to compute from | ||
*/ | ||
function getSourceClientOffset(state) { | ||
const { clientOffset, initialClientOffset, initialSourceClientOffset } = state; | ||
const { clientOffset , initialClientOffset , initialSourceClientOffset } = state; | ||
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) { | ||
@@ -43,10 +28,4 @@ return null; | ||
} | ||
exports.getSourceClientOffset = getSourceClientOffset; | ||
/** | ||
* Determines the x,y offset between the client offset and the initial client offset | ||
* | ||
* @param state The offset state to compute from | ||
*/ | ||
function getDifferenceFromInitialOffset(state) { | ||
const { clientOffset, initialClientOffset } = state; | ||
const { clientOffset , initialClientOffset } = state; | ||
if (!clientOffset || !initialClientOffset) { | ||
@@ -57,2 +36,3 @@ return null; | ||
} | ||
exports.getDifferenceFromInitialOffset = getDifferenceFromInitialOffset; | ||
//# sourceMappingURL=coords.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.areDirty = exports.ALL = exports.NONE = void 0; | ||
const js_utils_1 = require("./js_utils"); | ||
exports.NONE = []; | ||
exports.ALL = []; | ||
exports.NONE.__IS_NONE__ = true; | ||
exports.ALL.__IS_ALL__ = true; | ||
/** | ||
* Determines if the given handler IDs are dirty or not. | ||
* | ||
* @param dirtyIds The set of dirty handler ids | ||
* @param handlerIds The set of handler ids to check | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.areDirty = areDirty; | ||
exports.ALL = exports.NONE = void 0; | ||
var _jsUtils = require("./js_utils"); | ||
const NONE = []; | ||
exports.NONE = NONE; | ||
const ALL = []; | ||
exports.ALL = ALL; | ||
NONE.__IS_NONE__ = true; | ||
ALL.__IS_ALL__ = true; | ||
function areDirty(dirtyIds, handlerIds) { | ||
if (dirtyIds === exports.NONE) { | ||
if (dirtyIds === NONE) { | ||
return false; | ||
} | ||
if (dirtyIds === exports.ALL || typeof handlerIds === 'undefined') { | ||
if (dirtyIds === ALL || typeof handlerIds === 'undefined') { | ||
return true; | ||
} | ||
const commonIds = (0, js_utils_1.intersection)(handlerIds, dirtyIds); | ||
const commonIds = (0, _jsUtils).intersection(handlerIds, dirtyIds); | ||
return commonIds.length > 0; | ||
} | ||
exports.areDirty = areDirty; | ||
//# sourceMappingURL=dirtiness.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.areArraysEqual = exports.areCoordsEqual = exports.strictEquality = void 0; | ||
const strictEquality = (a, b) => a === b; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.areCoordsEqual = areCoordsEqual; | ||
exports.areArraysEqual = areArraysEqual; | ||
exports.strictEquality = void 0; | ||
const strictEquality = (a, b)=>a === b | ||
; | ||
exports.strictEquality = strictEquality; | ||
/** | ||
* Determine if two cartesian coordinate offsets are equal | ||
* @param offsetA | ||
* @param offsetB | ||
*/ | ||
function areCoordsEqual(offsetA, offsetB) { | ||
if (!offsetA && !offsetB) { | ||
return true; | ||
} | ||
else if (!offsetA || !offsetB) { | ||
} else if (!offsetA || !offsetB) { | ||
return false; | ||
} | ||
else { | ||
} else { | ||
return offsetA.x === offsetB.x && offsetA.y === offsetB.y; | ||
} | ||
} | ||
exports.areCoordsEqual = areCoordsEqual; | ||
/** | ||
* Determines if two arrays of items are equal | ||
* @param a The first array of items | ||
* @param b The second array of items | ||
*/ | ||
function areArraysEqual(a, b, isEqual = exports.strictEquality) { | ||
function areArraysEqual(a, b, isEqual = strictEquality) { | ||
if (a.length !== b.length) { | ||
return false; | ||
} | ||
for (let i = 0; i < a.length; ++i) { | ||
for(let i = 0; i < a.length; ++i){ | ||
if (!isEqual(a[i], b[i])) { | ||
@@ -39,2 +31,3 @@ return false; | ||
} | ||
exports.areArraysEqual = areArraysEqual; | ||
//# sourceMappingURL=equality.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNextUniqueId = void 0; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getNextUniqueId = getNextUniqueId; | ||
let nextUniqueId = 0; | ||
@@ -8,2 +10,3 @@ function getNextUniqueId() { | ||
} | ||
exports.getNextUniqueId = getNextUniqueId; | ||
//# sourceMappingURL=getNextUniqueId.js.map |
"use strict"; | ||
// cheap lodash replacements | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.intersection = exports.xor = exports.isObject = exports.isString = exports.without = exports.get = void 0; | ||
/** | ||
* drop-in replacement for _.get | ||
* @param obj | ||
* @param path | ||
* @param defaultValue | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.get = get; | ||
exports.without = without; | ||
exports.isString = isString; | ||
exports.isObject = isObject; | ||
exports.xor = xor; | ||
exports.intersection = intersection; | ||
function get(obj, path, defaultValue) { | ||
return path | ||
.split('.') | ||
.reduce((a, c) => (a && a[c] ? a[c] : defaultValue || null), obj); | ||
return path.split('.').reduce((a, c)=>a && a[c] ? a[c] : defaultValue || null | ||
, obj); | ||
} | ||
exports.get = get; | ||
/** | ||
* drop-in replacement for _.without | ||
*/ | ||
function without(items, item) { | ||
return items.filter((i) => i !== item); | ||
return items.filter((i)=>i !== item | ||
); | ||
} | ||
exports.without = without; | ||
/** | ||
* drop-in replacement for _.isString | ||
* @param input | ||
*/ | ||
function isString(input) { | ||
return typeof input === 'string'; | ||
} | ||
exports.isString = isString; | ||
/** | ||
* drop-in replacement for _.isString | ||
* @param input | ||
*/ | ||
function isObject(input) { | ||
return typeof input === 'object'; | ||
} | ||
exports.isObject = isObject; | ||
/** | ||
* replacement for _.xor | ||
* @param itemsA | ||
* @param itemsB | ||
*/ | ||
function xor(itemsA, itemsB) { | ||
const map = new Map(); | ||
const insertItem = (item) => { | ||
const insertItem = (item)=>{ | ||
map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
@@ -53,3 +33,3 @@ }; | ||
const result = []; | ||
map.forEach((count, key) => { | ||
map.forEach((count, key)=>{ | ||
if (count === 1) { | ||
@@ -61,11 +41,7 @@ result.push(key); | ||
} | ||
exports.xor = xor; | ||
/** | ||
* replacement for _.intersection | ||
* @param itemsA | ||
* @param itemsB | ||
*/ | ||
function intersection(itemsA, itemsB) { | ||
return itemsA.filter((t) => itemsB.indexOf(t) > -1); | ||
return itemsA.filter((t)=>itemsB.indexOf(t) > -1 | ||
); | ||
} | ||
exports.intersection = intersection; | ||
//# sourceMappingURL=js_utils.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matchesType = void 0; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.matchesType = matchesType; | ||
function matchesType(targetType, draggedItemType) { | ||
@@ -8,6 +10,6 @@ if (draggedItemType === null) { | ||
} | ||
return Array.isArray(targetType) | ||
? targetType.some((t) => t === draggedItemType) | ||
: targetType === draggedItemType; | ||
return Array.isArray(targetType) ? targetType.some((t)=>t === draggedItemType | ||
) : targetType === draggedItemType; | ||
} | ||
exports.matchesType = matchesType; | ||
//# sourceMappingURL=matchesType.js.map |
@@ -9,10 +9,10 @@ import { invariant } from '@react-dnd/invariant'; | ||
clientOffset: null, | ||
sourceClientOffset: null, | ||
}, | ||
sourceClientOffset: null | ||
} | ||
}; | ||
export function createBeginDrag(manager) { | ||
return function beginDrag(sourceIds = [], options = { | ||
publishSource: true, | ||
publishSource: true | ||
}) { | ||
const { publishSource = true, clientOffset, getSourceClientOffset, } = options; | ||
const { publishSource =true , clientOffset , getSourceClientOffset , } = options; | ||
const monitor = manager.getMonitor(); | ||
@@ -57,4 +57,4 @@ const registry = manager.getRegistry(); | ||
sourceClientOffset: sourceClientOffset || null, | ||
isSourcePublic: !!publishSource, | ||
}, | ||
isSourcePublic: !!publishSource | ||
} | ||
}; | ||
@@ -65,3 +65,3 @@ }; | ||
invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.'); | ||
sourceIds.forEach(function (sourceId) { | ||
sourceIds.forEach(function(sourceId) { | ||
invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.'); | ||
@@ -78,3 +78,3 @@ }); | ||
let sourceId = null; | ||
for (let i = sourceIds.length - 1; i >= 0; i--) { | ||
for(let i = sourceIds.length - 1; i >= 0; i--){ | ||
if (monitor.canDragSource(sourceIds[i])) { | ||
@@ -87,1 +87,3 @@ sourceId = sourceIds[i]; | ||
} | ||
//# sourceMappingURL=beginDrag.js.map |
import { invariant } from '@react-dnd/invariant'; | ||
import { DROP } from './types'; | ||
import { isObject } from '../../utils/js_utils'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
export function createDrop(manager) { | ||
@@ -11,3 +39,3 @@ return function drop(options = {}) { | ||
// Multiple actions are dispatched here, which is why this doesn't return an action | ||
targetIds.forEach((targetId, index) => { | ||
targetIds.forEach((targetId, index)=>{ | ||
const dropResult = determineDropResult(targetId, index, registry, monitor); | ||
@@ -17,7 +45,4 @@ const action = { | ||
payload: { | ||
dropResult: { | ||
...options, | ||
...dropResult, | ||
}, | ||
}, | ||
dropResult: _objectSpread({}, options, dropResult) | ||
} | ||
}; | ||
@@ -45,7 +70,7 @@ manager.dispatch(action); | ||
function getDroppableTargets(monitor) { | ||
const targetIds = monitor | ||
.getTargetIds() | ||
.filter(monitor.canDropOnTarget, monitor); | ||
const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor); | ||
targetIds.reverse(); | ||
return targetIds; | ||
} | ||
//# sourceMappingURL=drop.js.map |
@@ -14,3 +14,5 @@ import { invariant } from '@react-dnd/invariant'; | ||
} | ||
return { type: END_DRAG }; | ||
return { | ||
type: END_DRAG | ||
}; | ||
}; | ||
@@ -21,1 +23,3 @@ } | ||
} | ||
//# sourceMappingURL=endDrag.js.map |
@@ -5,3 +5,3 @@ import { invariant } from '@react-dnd/invariant'; | ||
export function createHover(manager) { | ||
return function hover(targetIdsArg, { clientOffset } = {}) { | ||
return function hover(targetIdsArg, { clientOffset } = {}) { | ||
verifyTargetIdsIsArray(targetIdsArg); | ||
@@ -19,4 +19,4 @@ const targetIds = targetIdsArg.slice(0); | ||
targetIds, | ||
clientOffset: clientOffset || null, | ||
}, | ||
clientOffset: clientOffset || null | ||
} | ||
}; | ||
@@ -31,3 +31,3 @@ }; | ||
invariant(!monitor.didDrop(), 'Cannot call hover after drop.'); | ||
for (let i = 0; i < targetIds.length; i++) { | ||
for(let i = 0; i < targetIds.length; i++){ | ||
const targetId = targetIds[i]; | ||
@@ -43,3 +43,3 @@ invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.'); | ||
// non-matching targets. | ||
for (let i = targetIds.length - 1; i >= 0; i--) { | ||
for(let i = targetIds.length - 1; i >= 0; i--){ | ||
const targetId = targetIds[i]; | ||
@@ -54,3 +54,3 @@ const targetType = registry.getTargetType(targetId); | ||
// Finally call hover on all matching targets. | ||
targetIds.forEach(function (targetId) { | ||
targetIds.forEach(function(targetId) { | ||
const target = registry.getTarget(targetId); | ||
@@ -60,1 +60,3 @@ target.hover(monitor, targetId); | ||
} | ||
//# sourceMappingURL=hover.js.map |
@@ -13,4 +13,6 @@ import { createBeginDrag } from './beginDrag'; | ||
drop: createDrop(manager), | ||
endDrag: createEndDrag(manager), | ||
endDrag: createEndDrag(manager) | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -7,5 +7,7 @@ import { INIT_COORDS } from '../types'; | ||
sourceClientOffset: sourceClientOffset || null, | ||
clientOffset: clientOffset || null, | ||
}, | ||
clientOffset: clientOffset || null | ||
} | ||
}; | ||
} | ||
//# sourceMappingURL=setClientOffset.js.map |
@@ -6,3 +6,5 @@ import { PUBLISH_DRAG_SOURCE } from './types'; | ||
if (monitor.isDragging()) { | ||
return { type: PUBLISH_DRAG_SOURCE }; | ||
return { | ||
type: PUBLISH_DRAG_SOURCE | ||
}; | ||
} | ||
@@ -12,1 +14,3 @@ return; | ||
} | ||
//# sourceMappingURL=publishDragSource.js.map |
@@ -7,1 +7,3 @@ export const INIT_COORDS = 'dnd-core/INIT_COORDS'; | ||
export const END_DRAG = 'dnd-core/END_DRAG'; | ||
//# sourceMappingURL=types.js.map |
@@ -9,4 +9,4 @@ export const ADD_SOURCE = 'dnd-core/ADD_SOURCE'; | ||
payload: { | ||
sourceId, | ||
}, | ||
sourceId | ||
} | ||
}; | ||
@@ -18,4 +18,4 @@ } | ||
payload: { | ||
targetId, | ||
}, | ||
targetId | ||
} | ||
}; | ||
@@ -27,4 +27,4 @@ } | ||
payload: { | ||
sourceId, | ||
}, | ||
sourceId | ||
} | ||
}; | ||
@@ -36,5 +36,7 @@ } | ||
payload: { | ||
targetId, | ||
}, | ||
targetId | ||
} | ||
}; | ||
} | ||
//# sourceMappingURL=registry.js.map |
import { createDragDropActions } from '../actions/dragDrop'; | ||
export class DragDropManagerImpl { | ||
store; | ||
monitor; | ||
backend; | ||
isSetUp = false; | ||
constructor(store, monitor) { | ||
this.store = store; | ||
this.monitor = monitor; | ||
store.subscribe(this.handleRefCountChange); | ||
} | ||
receiveBackend(backend) { | ||
@@ -25,7 +16,6 @@ this.backend = backend; | ||
getActions() { | ||
/* eslint-disable-next-line @typescript-eslint/no-this-alias */ | ||
const manager = this; | ||
const { dispatch } = this.store; | ||
/* eslint-disable-next-line @typescript-eslint/no-this-alias */ const manager = this; | ||
const { dispatch } = this.store; | ||
function bindActionCreator(actionCreator) { | ||
return (...args) => { | ||
return (...args)=>{ | ||
const action = actionCreator.apply(manager, args); | ||
@@ -38,3 +28,3 @@ if (typeof action !== 'undefined') { | ||
const actions = createDragDropActions(this); | ||
return Object.keys(actions).reduce((boundActions, key) => { | ||
return Object.keys(actions).reduce((boundActions, key)=>{ | ||
const action = actions[key]; | ||
@@ -48,15 +38,22 @@ boundActions[key] = bindActionCreator(action); | ||
} | ||
handleRefCountChange = () => { | ||
const shouldSetUp = this.store.getState().refCount > 0; | ||
if (this.backend) { | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
constructor(store, monitor){ | ||
this.isSetUp = false; | ||
this.handleRefCountChange = ()=>{ | ||
const shouldSetUp = this.store.getState().refCount > 0; | ||
if (this.backend) { | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
} else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
} | ||
else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
} | ||
}; | ||
}; | ||
this.store = store; | ||
this.monitor = monitor; | ||
store.subscribe(this.handleRefCountChange); | ||
} | ||
} | ||
//# sourceMappingURL=DragDropManagerImpl.js.map |
import { invariant } from '@react-dnd/invariant'; | ||
import { matchesType } from '../utils/matchesType'; | ||
import { getSourceClientOffset, getDifferenceFromInitialOffset, } from '../utils/coords'; | ||
import { getSourceClientOffset, getDifferenceFromInitialOffset } from '../utils/coords'; | ||
import { areDirty } from '../utils/dirtiness'; | ||
export class DragDropMonitorImpl { | ||
store; | ||
registry; | ||
constructor(store, registry) { | ||
this.store = store; | ||
this.registry = registry; | ||
} | ||
subscribeToStateChange(listener, options = {}) { | ||
const { handlerIds } = options; | ||
const { handlerIds } = options; | ||
invariant(typeof listener === 'function', 'listener must be a function.'); | ||
invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.'); | ||
let prevStateId = this.store.getState().stateId; | ||
const handleChange = () => { | ||
const handleChange = ()=>{ | ||
const state = this.store.getState(); | ||
const currentStateId = state.stateId; | ||
try { | ||
const canSkipListener = currentStateId === prevStateId || | ||
(currentStateId === prevStateId + 1 && | ||
!areDirty(state.dirtyHandlerIds, handlerIds)); | ||
const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds); | ||
if (!canSkipListener) { | ||
listener(); | ||
} | ||
} | ||
finally { | ||
} finally{ | ||
prevStateId = currentStateId; | ||
@@ -37,3 +28,3 @@ } | ||
let previousState = this.store.getState().dragOffset; | ||
const handleChange = () => { | ||
const handleChange = ()=>{ | ||
const nextState = this.store.getState().dragOffset; | ||
@@ -71,3 +62,3 @@ if (nextState === previousState) { | ||
const draggedItemType = this.getItemType(); | ||
return (matchesType(targetType, draggedItemType) && target.canDrop(this, targetId)); | ||
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId); | ||
} | ||
@@ -94,3 +85,5 @@ isDragging() { | ||
} | ||
isOverTarget(targetId, options = { shallow: false }) { | ||
isOverTarget(targetId, options = { | ||
shallow: false | ||
}) { | ||
// undefined on initial render | ||
@@ -100,3 +93,3 @@ if (!targetId) { | ||
} | ||
const { shallow } = options; | ||
const { shallow } = options; | ||
if (!this.isDragging()) { | ||
@@ -117,4 +110,3 @@ return false; | ||
return index === targetIds.length - 1; | ||
} | ||
else { | ||
} else { | ||
return index > -1; | ||
@@ -159,2 +151,8 @@ } | ||
} | ||
constructor(store, registry){ | ||
this.store = store; | ||
this.registry = registry; | ||
} | ||
} | ||
//# sourceMappingURL=DragDropMonitorImpl.js.map |
import { invariant } from '@react-dnd/invariant'; | ||
import { addSource, addTarget, removeSource, removeTarget, } from '../actions/registry'; | ||
import { addSource, addTarget, removeSource, removeTarget } from '../actions/registry'; | ||
import { getNextUniqueId } from '../utils/getNextUniqueId'; | ||
import { HandlerRole, } from '../interfaces'; | ||
import { validateSourceContract, validateTargetContract, validateType, } from '../contracts'; | ||
import { HandlerRole } from '../interfaces'; | ||
import { validateSourceContract, validateTargetContract, validateType } from '../contracts'; | ||
import { asap } from '@react-dnd/asap'; | ||
function getNextHandlerId(role) { | ||
const id = getNextUniqueId().toString(); | ||
switch (role) { | ||
switch(role){ | ||
case HandlerRole.SOURCE: | ||
@@ -19,3 +19,3 @@ return `S${id}`; | ||
function parseRoleFromHandlerId(handlerId) { | ||
switch (handlerId[0]) { | ||
switch(handlerId[0]){ | ||
case 'S': | ||
@@ -33,3 +33,3 @@ return HandlerRole.SOURCE; | ||
do { | ||
const { done, value: [, value], } = entries.next(); | ||
const { done , value: [, value] , } = entries.next(); | ||
if (value === searchValue) { | ||
@@ -39,15 +39,6 @@ return true; | ||
isDone = !!done; | ||
} while (!isDone); | ||
}while (!isDone) | ||
return false; | ||
} | ||
export class HandlerRegistryImpl { | ||
types = new Map(); | ||
dragSources = new Map(); | ||
dropTargets = new Map(); | ||
pinnedSourceId = null; | ||
pinnedSource = null; | ||
store; | ||
constructor(store) { | ||
this.store = store; | ||
} | ||
addSource(type, source) { | ||
@@ -68,4 +59,3 @@ validateType(type); | ||
containsHandler(handler) { | ||
return (mapContainsValue(this.dragSources, handler) || | ||
mapContainsValue(this.dropTargets, handler)); | ||
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler); | ||
} | ||
@@ -101,3 +91,3 @@ getSource(sourceId, includePinned = false) { | ||
this.store.dispatch(removeSource(sourceId)); | ||
asap(() => { | ||
asap(()=>{ | ||
this.dragSources.delete(sourceId); | ||
@@ -129,4 +119,3 @@ this.types.delete(sourceId); | ||
this.dragSources.set(id, handler); | ||
} | ||
else if (role === HandlerRole.TARGET) { | ||
} else if (role === HandlerRole.TARGET) { | ||
this.dropTargets.set(id, handler); | ||
@@ -136,2 +125,12 @@ } | ||
} | ||
constructor(store){ | ||
this.types = new Map(); | ||
this.dragSources = new Map(); | ||
this.dropTargets = new Map(); | ||
this.pinnedSourceId = null; | ||
this.pinnedSource = null; | ||
this.store = store; | ||
} | ||
} | ||
//# sourceMappingURL=HandlerRegistryImpl.js.map |
@@ -14,8 +14,9 @@ import { invariant } from '@react-dnd/invariant'; | ||
if (allowArray && Array.isArray(type)) { | ||
type.forEach((t) => validateType(t, false)); | ||
type.forEach((t)=>validateType(t, false) | ||
); | ||
return; | ||
} | ||
invariant(typeof type === 'string' || typeof type === 'symbol', allowArray | ||
? 'Type can only be a string, a symbol, or an array of either.' | ||
: 'Type can only be a string or a symbol.'); | ||
invariant(typeof type === 'string' || typeof type === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.'); | ||
} | ||
//# sourceMappingURL=contracts.js.map |
@@ -17,10 +17,9 @@ import { DragDropManagerImpl } from './classes/DragDropManagerImpl'; | ||
// we'll need to consider how to pull off dev-tooling | ||
const reduxDevTools = typeof window !== 'undefined' && | ||
window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return createStore(reduce, debugMode && | ||
reduxDevTools && | ||
reduxDevTools({ | ||
name: 'dnd-core', | ||
instanceId: 'dnd-core', | ||
})); | ||
const reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return createStore(reduce, debugMode && reduxDevTools && reduxDevTools({ | ||
name: 'dnd-core', | ||
instanceId: 'dnd-core' | ||
})); | ||
} | ||
//# sourceMappingURL=createDragDropManager.js.map |
export * from './interfaces'; | ||
export * from './createDragDropManager'; | ||
//# sourceMappingURL=index.js.map |
export var HandlerRole; | ||
(function (HandlerRole) { | ||
(function(HandlerRole) { | ||
HandlerRole["SOURCE"] = "SOURCE"; | ||
HandlerRole["TARGET"] = "TARGET"; | ||
})(HandlerRole || (HandlerRole = {})); | ||
//# sourceMappingURL=interfaces.js.map |
@@ -1,10 +0,9 @@ | ||
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP, } from '../actions/dragDrop'; | ||
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET, } from '../actions/registry'; | ||
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop'; | ||
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry'; | ||
import { areArraysEqual } from '../utils/equality'; | ||
import { NONE, ALL } from '../utils/dirtiness'; | ||
import { xor } from '../utils/js_utils'; | ||
export function reduce( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function reduce(// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_state = NONE, action) { | ||
switch (action.type) { | ||
switch(action.type){ | ||
case HOVER: | ||
@@ -24,3 +23,3 @@ break; | ||
} | ||
const { targetIds = [], prevTargetIds = [] } = action.payload; | ||
const { targetIds =[] , prevTargetIds =[] } = action.payload; | ||
const result = xor(targetIds, prevTargetIds); | ||
@@ -45,1 +44,3 @@ const didChange = result.length > 0 || !areArraysEqual(targetIds, prevTargetIds); | ||
} | ||
//# sourceMappingURL=dirtyHandlerIds.js.map |
@@ -1,11 +0,39 @@ | ||
import { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP, } from '../actions/dragDrop'; | ||
import { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP } from '../actions/dragDrop'; | ||
import { areCoordsEqual } from '../utils/equality'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
const initialState = { | ||
initialSourceClientOffset: null, | ||
initialClientOffset: null, | ||
clientOffset: null, | ||
clientOffset: null | ||
}; | ||
export function reduce(state = initialState, action) { | ||
const { payload } = action; | ||
switch (action.type) { | ||
const { payload } = action; | ||
switch(action.type){ | ||
case INIT_COORDS: | ||
@@ -16,3 +44,3 @@ case BEGIN_DRAG: | ||
initialClientOffset: payload.clientOffset, | ||
clientOffset: payload.clientOffset, | ||
clientOffset: payload.clientOffset | ||
}; | ||
@@ -23,6 +51,5 @@ case HOVER: | ||
} | ||
return { | ||
...state, | ||
clientOffset: payload.clientOffset, | ||
}; | ||
return _objectSpread({}, state, { | ||
clientOffset: payload.clientOffset | ||
}); | ||
case END_DRAG: | ||
@@ -35,1 +62,3 @@ case DROP: | ||
} | ||
//# sourceMappingURL=dragOffset.js.map |
@@ -1,4 +0,32 @@ | ||
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP, } from '../actions/dragDrop'; | ||
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop'; | ||
import { REMOVE_TARGET } from '../actions/registry'; | ||
import { without } from '../utils/js_utils'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
const initialState = { | ||
@@ -11,10 +39,9 @@ itemType: null, | ||
didDrop: false, | ||
isSourcePublic: null, | ||
isSourcePublic: null | ||
}; | ||
export function reduce(state = initialState, action) { | ||
const { payload } = action; | ||
switch (action.type) { | ||
const { payload } = action; | ||
switch(action.type){ | ||
case BEGIN_DRAG: | ||
return { | ||
...state, | ||
return _objectSpread({}, state, { | ||
itemType: payload.itemType, | ||
@@ -25,14 +52,12 @@ item: payload.item, | ||
dropResult: null, | ||
didDrop: false, | ||
}; | ||
didDrop: false | ||
}); | ||
case PUBLISH_DRAG_SOURCE: | ||
return { | ||
...state, | ||
isSourcePublic: true, | ||
}; | ||
return _objectSpread({}, state, { | ||
isSourcePublic: true | ||
}); | ||
case HOVER: | ||
return { | ||
...state, | ||
targetIds: payload.targetIds, | ||
}; | ||
return _objectSpread({}, state, { | ||
targetIds: payload.targetIds | ||
}); | ||
case REMOVE_TARGET: | ||
@@ -42,16 +67,13 @@ if (state.targetIds.indexOf(payload.targetId) === -1) { | ||
} | ||
return { | ||
...state, | ||
targetIds: without(state.targetIds, payload.targetId), | ||
}; | ||
return _objectSpread({}, state, { | ||
targetIds: without(state.targetIds, payload.targetId) | ||
}); | ||
case DROP: | ||
return { | ||
...state, | ||
return _objectSpread({}, state, { | ||
dropResult: payload.dropResult, | ||
didDrop: true, | ||
targetIds: [], | ||
}; | ||
targetIds: [] | ||
}); | ||
case END_DRAG: | ||
return { | ||
...state, | ||
return _objectSpread({}, state, { | ||
itemType: null, | ||
@@ -63,4 +85,4 @@ item: null, | ||
isSourcePublic: null, | ||
targetIds: [], | ||
}; | ||